
Purfleet
England
Member
Members

Trusted Members

Trusted Members

Forum Posts: 414
Member Since:
December 20, 2019
December 20, 2019

Probably the most useful piece of code I have learnt.
Sub FindLastRow()
Dim Lr As Long
Lr = Cells(Rows.Count, 1).End(xlUp).Row
Debug.Print Lr
Range("a1:a" & Lr).Select
End Sub
This code will check, from the bottom upwards, and find hte last used row, you can then use the variable of LR to create a range like Range("a1:a" & Lr) and do what you need to with it. the number 1 in the middle is the column number you want to check so if you need to find the last used row in column E you would put in 5 and so on.
The variable letters can be changed to whatever suits (within reason)
Purfleet
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Aminu Sule
Samuel Ramirez
Abdifatah Osman
mohad borhom
Abayomi Adedeji
Ganesh MVS
Gilbert Lemek
Ashleigh Farquharson
Jayz Luu
Fred Smith
Forum Stats:
Groups: 3
Forums: 24
Topics: 6364
Posts: 27828
Member Stats:
Guest Posters: 49
Members: 32346
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —
