What I would like the following Workbook Close even to do is
E1 of every sheet except one called "AHOD" to populate today's date
Then I'd like it to look at E1 and if the date is anything other than today's, to Clear Contents on G1.
This is to ensure that G1 only gets cleared once a day, not every time I close the workbook.
The problem is that it only seems to be doing it on the last worksheet that I hit Save on before I closed the Workbook. I'm sure it's just a silly syntax error but I'm at a loss. Any help (as usual on this fantastic site) is always appreciated.
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
With ws
Range("E1") = Date
Range("E1").NumberFormat = "m/d/yyyy"
If Range("E1").Value < Date Then
Range("G1").ClearContents
End If
End With
Next ws
End Sub
I know the code above won't exclude the "AHOD" worksheet so I wrote the following, but I also likely made a syntax error.
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "AHOD" Then
With ws
Range("E1") = Date
Range("E1").NumberFormat = "m/d/yyyy"
If Range("E1").Value < Date Then
Range("G1").ClearContents
End If
End With
Next ws
End Sub
Bookmarks