ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unhide Rows Date Older Than 7 Days (https://www.excelbanter.com/excel-programming/398985-unhide-rows-date-older-than-7-days.html)

Dean P.

Unhide Rows Date Older Than 7 Days
 

I would like to create a macro to unhide rows in Sheet1 with Dates in Column
(C) that are older than 7 days old from current day. The Dates are in Column
(C) starting in row 2.

Please help me create this unhide macro.

Thanks,

Dean P.



joel

Unhide Rows Date Older Than 7 Days
 

Sub hiderows()

'unhide everything
Cells.Select
Selection.EntireColumn.Hidden = False
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
Set ColCRange = Range("C1:C" & LastRow)

For Each cell In ColCRange
If Date - cell.Value 7 Then
Cells.EntireRow.Hidden = True
End If

Next cell


End Sub
"Dean P." wrote:


I would like to create a macro to unhide rows in Sheet1 with Dates in Column
(C) that are older than 7 days old from current day. The Dates are in Column
(C) starting in row 2.

Please help me create this unhide macro.

Thanks,

Dean P.



JW[_2_]

Unhide Rows Date Older Than 7 Days
 
One way:
Sub this()
Rows.Hidden = False
For i = 2 To Cells(Rows.Count, 3).End(xlUp).Row
If Not IsDate(Cells(i, 3).Value) Or _
Not Cells(i, 3).Value < Date - 7 Then _
Cells(i, 3).EntireRow.Hidden = True
Next i
End Sub

This will hide anything that is not a date as well.
Dean P. wrote:
I would like to create a macro to unhide rows in Sheet1 with Dates in Column
(C) that are older than 7 days old from current day. The Dates are in Column
(C) starting in row 2.

Please help me create this unhide macro.

Thanks,

Dean P.




All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com