Custom color current week tab based on today

52 views Asked by At

Any help is greatly appreciated.

I have a workbook with multiple sheets labeled W1, W2, and so on. Each sheet has the week starting date in A1 and the ending date in A2.

I would like to color the tab a specific RBG based on if today falls into the range for that sheets dates.

Any suggestions for VBA?

I have tried several things like active sheet and color all tabs but I am not getting the code right.

1

There are 1 answers

1
Ike On

Try this code

Sub colorTabs()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
    If ws.Range("A1") <= Date And Date <= ws.Range("A2") Then
        ws.Tab.Color = vbRed
    Else
        ws.Tab.Color = vbWhite
    End If
Next
End Sub