PDA

View Full Version : Solved: finding last row w/ (xldown)



YellowLabPro
10-06-2007, 07:00 AM
I use .end(xlup) all the time.
This time I wanted to use (xldown).

The last row of data is in row 8.

This line tells me that the last row is 65,536, not 8. Is this correct? What property should I use to find row 8 going down?

lrow = Cells(Rows.Count, 1).End(xlDown).Row

Gert Jan
10-06-2007, 07:09 AM
When using Rows.count you start at the bottom, going down leaves you at the bottom, so lrow is always 65536.

You could try
lrow = Cells(1, 1).End(xlDown).Row

YellowLabPro
10-06-2007, 07:33 AM
Thanks Gert,
works fine.
But let me clarfy your point.
You are saying count starts at the bottom of the sheet, not at the top?

Gert Jan
10-06-2007, 07:45 AM
Try this one out

Sub test()
Dim lrow As Long
lrow = Cells(Rows.Count, 1).Row
MsgBox lrow
End Sub

Bob Phillips
10-06-2007, 08:52 AM
NO, he is saying that if you set the start row to Rows.Count, then it will start at the bottom of the sheet.

Gert Jan
10-06-2007, 09:20 AM
NO, he is saying that if you set the start row to Rows.Count, then it will start at the bottom of the sheet.

Thanks for explaining, i should have been a bit more complete in my reply.:blush

Gert Jan

YellowLabPro
10-06-2007, 09:38 AM
Subtle differences.... spices of life....

thanks Gert and Bob