Eloise T
Active Member
Below is my VBA that allows me to toggle between magenta and green and none (default) tab colors. I would like to add a third color. How do I change to VBA code to allow a third color? ...e.g. black. So it would go from none (default) to magenta to green to black.
Sub Swap_Tab_Color()
Application.ScreenUpdating = False
a_tab = ActiveSheet.Name
a_color = Worksheets(a_tab).Tab.ColorIndex
' 1 = black, 3 = red, 4 = green, 7 = magenta
If a_color = 7 Then
a_color = 4
ElseIf a_color = 4 Then
a_color = xlNone
Else: a_color = xlNone
a_color = 7
End If
Worksheets(a_tab).Tab.ColorIndex = a_color
End Sub
Sub Swap_Tab_Color()
Application.ScreenUpdating = False
a_tab = ActiveSheet.Name
a_color = Worksheets(a_tab).Tab.ColorIndex
' 1 = black, 3 = red, 4 = green, 7 = magenta
If a_color = 7 Then
a_color = 4
ElseIf a_color = 4 Then
a_color = xlNone
Else: a_color = xlNone
a_color = 7
End If
Worksheets(a_tab).Tab.ColorIndex = a_color
End Sub