ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find last row of data (https://www.excelbanter.com/excel-programming/318478-find-last-row-data.html)

delali

find last row of data
 
hi,
i was wondering if there is a function that returns the row number of the
last row of data in a file.
i usually just loop down a column until cell value is empty but now i have a
file that has empty cells in betweenm and this doesn't work.

thanx a lot

Norman Jones

find last row of data
 
Hi Delali,

Try:

Dim rw As Long
rw = Cells(Rows.Count, "A").End(xlUp).Row

---
Regards,
Norman



"delali" wrote in message
...
hi,
i was wondering if there is a function that returns the row number of the
last row of data in a file.
i usually just loop down a column until cell value is empty but now i have
a
file that has empty cells in betweenm and this doesn't work.

thanx a lot




Alan Beban[_2_]

find last row of data
 
delali wrote:
hi,
i was wondering if there is a function that returns the row number of the
last row of data in a file.
i usually just loop down a column until cell value is empty but now i have a
file that has empty cells in betweenm and this doesn't work.

thanx a lot


You could just continue to loop a la

For i = 65536 To 1 Step -1
If Range("A" & i).Value < "" Then Exit For
Next
rw = i

Unlike Norman Jones's suggestion, this will work if the last row of
Column A has data.

Perhaps faster for the same functionality would be to use the Find
method, searching from Cell A1 backwards.

Alan Beban

Tom Ogilvy

find last row of data
 
Dim rw As Long
if not isempty(Range("A" & rows.count)) then
rw = rows.count
else
rw = Cells(Rows.Count, "A").End(xlUp).Row
End if

would also account for the last cell having data.

--
Regards,
Tom Ogilvy

"Alan Beban" wrote in message
...
delali wrote:
hi,
i was wondering if there is a function that returns the row number of

the
last row of data in a file.
i usually just loop down a column until cell value is empty but now i

have a
file that has empty cells in betweenm and this doesn't work.

thanx a lot


You could just continue to loop a la

For i = 65536 To 1 Step -1
If Range("A" & i).Value < "" Then Exit For
Next
rw = i

Unlike Norman Jones's suggestion, this will work if the last row of
Column A has data.

Perhaps faster for the same functionality would be to use the Find
method, searching from Cell A1 backwards.

Alan Beban





All times are GMT +1. The time now is 09:21 AM.

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