Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CurrentRegion

Status
Not open for further replies.

ching0418

MIS
Mar 6, 2002
96
HK
hello,

i want to know the number of rows of an excel file. i searched in this forum and found that i can use the .CurrentRegion function. But when, i tried it, it says that the object doesn't support the property or method.

I have the ff code:

Dim wkbobj As Workbook
Set wkbobj = GetObject(codOpen.FileName)
z = wkbobj.ActiveCell.CurrentRegion

i think something's worng with it. please help!!!

TIA,
ching
 
You should be able to get that information from the UsedRange object within the Worksheet Object. the UsedRange Object contains two collection (Rows and Columns) each which have a count property.

XLApp.ActiveWorkbook.Sheets(1).UsedRange.Rows.Count
XLApp.ActiveWorkbook.Sheets(1).UsedRange.Columns.Count
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top