Hello,
I'm trying to get a macro to work that will make tabs visible based on a date entered into cell "c2" of each worksheet. There is a new worksheet for each day, and I'd like today's sheet's tab to be visible as well as the sheet's tabs for the upcoming 7 days, and then hiding any previous day's tabs.
So far I have this...
[code]
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
If (ws.Range("C2") < Date And ws.Range("C2") > (Date + 7)) Then
ws.Visible = False
End If
Next ws
End Sub
[code]
...but nothing is hiding. It will hide if I have "<> Date", but then only today's tab will show, and that isn't helpful. Any suggestions will be greatly appreciated!
Thanks!
Last edited by a_dub_green; 01-13-2012 at 10:53 AM.
Hi,
Try this code
Private Sub Workbook_Open() On Error Resume Next Dim ws As Worksheet Worksheets(Worksheets.Count).Visible = True For Each ws In Worksheets ws.Visible = (ws.Range("C2") >= Date And ws.Range("C2") <= (Date + 7)) Next ws End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks