Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to hide rows not working Al Excel Discussion (Misc queries) 14 September 16th 08 05:53 PM
Auto-Hide Rows Macro txtstorer Excel Worksheet Functions 1 August 20th 08 08:54 PM
Macro to hide rows lightbulb Excel Discussion (Misc queries) 4 July 11th 08 06:13 PM
hide rows with macro Macro to hide rows in spreadwsheet Excel Discussion (Misc queries) 3 May 12th 05 05:02 PM
macro to hide rows david Excel Discussion (Misc queries) 3 April 8th 05 03:25 PM


All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"