ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding row number at the bottom of a block of data (https://www.excelbanter.com/excel-programming/384180-finding-row-number-bottom-block-data.html)

Andreww

Finding row number at the bottom of a block of data
 
Hi - Essentially I need to find how many records in a worksheet.

I can do

Sub test1()
Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
End Sub

Which taked me to the end of the block of data, but how do I:

a) Find the rownumber the curser stopped at?
b) put the cell address into a cell on a refernce sheet?

Any ideas?

Thanks

Andrew


Tim Williams

Finding row number at the bottom of a block of data
 
To avoid stopping at a gap in the data it's usually better to start at the bottom....

dim r as range

set r=sheet1.cells(sheet1.rows.count,1).end(xlup)

then you can use

r.row
r.address



--
Tim Williams
Palo Alto, CA


"Andreww" wrote in message ps.com...
Hi - Essentially I need to find how many records in a worksheet.

I can do

Sub test1()
Sheets("Data").Select
Range("A1").Select
Selection.End(xlDown).Select
End Sub

Which taked me to the end of the block of data, but how do I:

a) Find the rownumber the curser stopped at?
b) put the cell address into a cell on a refernce sheet?

Any ideas?

Thanks

Andrew




Andreww

Finding row number at the bottom of a block of data
 
Splendid!

I'll try it in the morning.

Regards

Andrew



All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com