r = ActiveSheet.Range("A1048576").End(xlUp).Row returns zero

billritz

New Member
Joined
Aug 20, 2012
Messages
25
With 30K rows in sheet and none blank in column A, how could this return a zero to r?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How are you seeing that it is returning zero ?
Can you show us all the code ? (please use the VBA button when you post the code)
 
Upvote 0
Yeah, as Alex suggests, that should not be possible, as there is no row 0 on any Excel sheet!
Are you sure that you are not subtracting one from it or something? That could lead you to zero if if goes up to row one.
If that really is your result, then you most likely have some sort of logic or coding error. If you post your code, as Alex asked, we may be able to spot where the issue is.

BTW, instead of using:
VBA Code:
r = Range("A1048576").End(xlUp).Row
I usually like to use this instead, which will also work on older versions of Excel that do not have that many rows (a more universal solution):
VBA Code:
r = Cells(Rows.Count, "A").End(xlUp).Row

BTW, you do not have to preface your range with "ActiveSheet". If you leave the sheet reference off, it assumes and runs against the ActiveSheet.

 
Upvote 0

Forum statistics

Threads
1,225,969
Messages
6,188,111
Members
453,460
Latest member
Cjohnson3

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