Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to automatically hide rows based on 3 cells | Excel Programming | |||
Automatically update a cell with a date based on anther cells date | Excel Discussion (Misc queries) | |||
VBA that automatically generates a series of cash flows based on a start date, an end date and frequency | Excel Programming | |||
Can Excel hide a row automatically based on value in a cell? | Excel Programming | |||
How do I automatically hide columns in a worksheet based on a cell value? | Excel Worksheet Functions |