![]() |
A macro that will hide all but the last 20 dated rows.
I have a spreadsheet where the leftmost column is dates in ascending order. I
want to write a macro that will hide all but the last 20 dated rows. Cany anybody help please. -- Mac Macdonald |
A macro that will hide all but the last 20 dated rows.
in Excel 2003
Sub hide() Dim counter As Integer ActiveSheet.Range("A65536").Select Selection.End(xlUp).Select For i = 1 To Selection.Row If Len(Selection) 0 And IsDate(Selection) Then counter = counter + 1 If counter <= 2 Then Selection.Rows.EntireRow.Hidden = True Else Exit For End If End If Selection.Offset(-1, 0).Select Next i End Sub for Excel 2007 adjust the "ActiveSheet.Range("A65536").Select" row accordingly HIH |
All times are GMT +1. The time now is 06:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com