Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find formatting doesn't work: "Excel cannot find data" Kasama Excel Discussion (Misc queries) 1 August 18th 06 01:40 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
The match and lookup functions can find literal data but not the same data referenced from a cell Jeff Melvaine Excel Discussion (Misc queries) 3 April 30th 05 01:29 PM
FIND DATA WITHIN DATA (V-OR-H LOOKUP/FIND/MATCH?) Jaladino Excel Worksheet Functions 0 February 22nd 05 11:22 PM
I need to find a macro to find data cut and paste to another colu. Rex Excel Programming 6 December 7th 04 09:22 AM


All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"