When the workbook opens I want it hide all sheets if date in Range("P1") is passed. I tried this code however it hides some sheet that the date has not passed and has other sheets visible when date is passed
VBA Code:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
If Range("P1") < Now Then
ws.Visible = xlSheetHidden
'Else
'ws.Visible = xlSheetVisible
End If
Next ws
Set ws = Nothing
End Sub