Eloise T
Active Member
This VBA macro allows me to toggle a "button" inside each Tab of my workbook which simply changes the color of the Tab I am working in.
The color toggles from red to the default color (off) on the Tab. I use this to remind myself if I've "updated" the contents of that Tab this week or not.
I wish to add a third color (green), so that when I hit the button the first time it becomes red, the second time I hit the button the Tab turns green, and the third time I hit the button it returns to the default color (off). Essentially it becomes a three-way toggle.
Here is the VBA macro that toggles from red to off. How do I change the If/Else to add the second color/third option?
THANKS!
MOD Edit: Code Tags added!
The color toggles from red to the default color (off) on the Tab. I use this to remind myself if I've "updated" the contents of that Tab this week or not.
I wish to add a third color (green), so that when I hit the button the first time it becomes red, the second time I hit the button the Tab turns green, and the third time I hit the button it returns to the default color (off). Essentially it becomes a three-way toggle.
Here is the VBA macro that toggles from red to off. How do I change the If/Else to add the second color/third option?
Code:
Sub Swap_Tab_Color()
Application.ScreenUpdating = False
a_tab = ActiveSheet.Name
a_color = Worksheets(a_tab).Tab.ColorIndex
' 3 = red, 4 = green, 7 = magenta
If a_color = 3 Then
a_color = xlNone
Else
a_color = 3
End If
Worksheets(a_tab).Tab.ColorIndex = a_color
End Sub
MOD Edit: Code Tags added!