Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

determine total rows in Excel sheet (2003 or 2007)

Posted on 2014-02-02
4
Medium Priority
?
431 Views
Last Modified: 2014-02-02
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.
0
Comment
Question by:developingprogrammer
4 Comments
 
LVL 16

Assisted Solution

by:Peter Kwan
Peter Kwan earned 668 total points
ID: 39828674
You may use:

Sheet1.Range("A:A").End(xlDown).Row
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 668 total points
ID: 39828679
intLastRowOfSheet = sheet1.rows.count
0
 
LVL 18

Assisted Solution

by:Steven Harris
Steven Harris earned 664 total points
ID: 39828689
ActiveSheet.Rows.Count
0
 

Author Closing Comment

by:developingprogrammer
ID: 39828691
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question