Hi all,
I want to hide rows based on a timestamp in column A. If the timestamp is a day old, hide the row. The code below used to work great but I just updated the workbook and the problem is that the code is only working for one of the worksheets (past date rows are hidden), while the other 4 are unaffected (past date rows not hidden).
What I changed is I used to have 2 separate columns, one for the date which was formatted MM/DD/YYYY (column A) and one for the time (column B). I've now consolidated the two columns into one and changed the format to MM/DD/YYYY HH:SS (column A). I think the problem is with the Next statement, which is why the code is working for one worksheet but not the others, but I'm not sure. Thank you in advance.
-Nick
I want to hide rows based on a timestamp in column A. If the timestamp is a day old, hide the row. The code below used to work great but I just updated the workbook and the problem is that the code is only working for one of the worksheets (past date rows are hidden), while the other 4 are unaffected (past date rows not hidden).
Code:
Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="wmd", Userinterfaceonly:=True
Next ws
Dim MyRange As Range, c As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set MyRange = Range("A2:A50000")
MyRange.EntireRow.Hidden = False
For Each c In MyRange
If IsDate(c.Value) And c.Value < Date Then
c.EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
What I changed is I used to have 2 separate columns, one for the date which was formatted MM/DD/YYYY (column A) and one for the time (column B). I've now consolidated the two columns into one and changed the format to MM/DD/YYYY HH:SS (column A). I think the problem is with the Next statement, which is why the code is working for one worksheet but not the others, but I'm not sure. Thank you in advance.
-Nick