Excel - Select Last 25 Records

[Solved/Closed]
Report
-
Posts
2811
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 27, 2021
-
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?

1 reply

Posts
2811
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 27, 2021
484
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