Excel - Select Last 25 Records

Solved/Closed
Wato89642b - Oct 10, 2011 at 07:52 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Oct 10, 2011 at 09:49 AM
Hi I have a spreadsheet that is entered into daily a list of actions taken in a department. This needs to be printed weekly and displayed. Obviously this will be easy to start with but as more and more entries are put on the list I want a macro that will only select the most recent 25 entries, these will be the last 25 entries on the list.

Any ideas?
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Oct 10, 2011 at 09:49 AM
Hi Wato89642b,

You didn't mention any range, so I'm guessing you want to select the last 25 rows.
Assuming that column A is filled with data.

Try this macro:
Sub Last25Rows()
Dim sRow As Integer
Dim lrow As Integer
sRow = Range("A" & Rows.Count).End(xlUp).Offset(-24, 0).Row
lrow = Range("A" & Rows.Count).End(xlUp).Row
Range(Rows(sRow), Rows(lrow)).Select
End Sub

Best regards,
Trowa
0