Rows.Count Returns 1M+ Rows

goss

Active Member
Joined
Feb 2, 2004
Messages
372
Hi all,

Using Excel 2010.

My Rows.Count continues to return 1,048,576 after initial import from csv
I subsequently deleted everything below row 100,003, but Rows.Count continues to return the 1M+. I highlighted the rows that have nothing in them and cleared all. Still 1M+ rows

I tried saving and re-opening the file. Same result.
How can I get the correct value of 100,003?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Rows.Count is the number of rows in an Excel 2007 and 2010 spreadsheet.

What you need is ActiveSheet.UsedRange.Rows.Count
 
Upvote 0
Thanks Wigi,

Too much Excel today - time to take a break.
Here is my final snippet. Returns 100,003
Code:
lngRows = ws.Cells(Rows.Count, 1).End(xlUp).Row
 
Upvote 0
Or better:

Code:
lngRows = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top