Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Hide row automatically based on date


I want my spreadsheet to look the date in colum C of each row. If the date
is more than 4 years old I'd like the row to be hidden. Any way to do this
automatically?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Hide row automatically based on date


Perhaps something like this. I assumed your data in Column C starts in C2
down. HTH Otto

Sub HideRows()
Dim rColC As Range
Dim i As Range
Set rColC = Range("C2", Range("C" & Rows.Count).End(xlUp))
For Each i In rColC
If DateSerial(Year(Date) - 4, Month(Date), Day(Date)) i.Value Then
i.EntireRow.Hidden = True
End If
Next i
End Sub
"Munchkin" wrote in message
...
I want my spreadsheet to look the date in colum C of each row. If the date
is more than 4 years old I'd like the row to be hidden. Any way to do
this
automatically?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Hide row automatically based on date


Try the below macro..You can either run this as a macro or paste the code in
workbook Close event or Open event ...Try and feedback..

Sub HideRows()
Dim lngRow as Long
For lngRow = 1 To Cells(Rows.Count, 3).End(xlUp).Row
If DateDiff("m", Range("c" & lngRow), Date) 48 And _
0 + Range("c" & lngRow) < 0 Then Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Munchkin" wrote:

I want my spreadsheet to look the date in colum C of each row. If the date
is more than 4 years old I'd like the row to be hidden. Any way to do this
automatically?

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 automatically hide rows based on 3 cells JAson Excel Programming 2 May 14th 09 04:32 AM
Automatically update a cell with a date based on anther cells date GPR GUY Excel Discussion (Misc queries) 2 November 3rd 08 03:57 PM
VBA that automatically generates a series of cash flows based on a start date, an end date and frequency [email protected] Excel Programming 0 December 27th 05 09:59 PM
Can Excel hide a row automatically based on value in a cell? RJQMAN[_3_] Excel Programming 2 July 7th 05 08:56 AM
How do I automatically hide columns in a worksheet based on a cell value? dkhedkar Excel Worksheet Functions 1 March 5th 05 12:20 AM


All times are GMT +1. The time now is 04:35 PM.

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

About Us

"It's about Microsoft Excel"