determine total rows in Excel sheet (2003 or 2007)

hey guys,

i've got this code

        Select Case penmExcelVersion
            Case enmExcel2003
                intLastRowOfSheet = 65536
            Case enmExcel2007
                intLastRowOfSheet = 1048576
        End Select

Open in new window


Question: what's the best way to check if the excel sheet i'm looking at has 65536 rows or 1048576 rows?

Homework: i can't use Application.Version because Excel 2007 can also create Excel 2003 sheets (.xls) which has 65536. i can't use the extension name (or rather it's not that reliable) because if i'm detecting for .xls, what if there's an xlt? yes i can list down all the Excel 2003 extensions but doesn't seem very elegant.
developingprogrammerAsked:
Who is Participating?
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
intLastRowOfSheet = sheet1.rows.count
0
 
Peter KwanConnect With a Mentor Analyst ProgrammerCommented:
You may use:

Sheet1.Range("A:A").End(xlDown).Row
0
 
Steven HarrisConnect With a Mentor PresidentCommented:
ActiveSheet.Rows.Count
0
 
developingprogrammerAuthor Commented:
whao fantastic guys! i've always been looking for something like this but using workarounds instead - now i feel so much more like a complete person ha = ) thanks guys!! = ))
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.