Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find row # of last record in Excel??

Status
Not open for further replies.

flip79

MIS
Jul 5, 2002
23
US
I am trying to create a macro that copies the values of one cell and pastes it into another cell. Each time the macro is run the number of records might be different. How can I find the row number of the last record, so my macro doesn't copy empty cells over?
 
Range("A65536").End(xlUp).Select
or
Range("A1", Range("A1").End(xlDown)).Select
or
Range(ActiveCell, ActiveCell.End(xlDown)).Select


Indu
 
Just to add to Indu's reply: If you need to know the row number inside your routine you could use something like the following:

Code:
LastRow = Range("A65536").End(xlUp).Row

where LastRow should be declared as Long

Regards,
M. Smith
 
Bit of shameless self promotion here but there is a FAQ on this (well, 2 actually) in the VBA formum FAQs
faq707-2115
and
faq707-2112

These 2 combined, have at least 4 different ways of acurately finding the last used cell....and I know there's a load of others, including Mike's and Indu's
HTH
~Geoff~
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top