Ok, my goal is to change the Tab color based on the conditional color of a range of cells. If any cell in the range is red, the tab color is red; or if any cell in the range is yellow, the tab color is yellow, else tab color will be green. I got the code to work when checking one cell only, but when I extend the range it is behaving like ALL the cells in the range have to meet the criteria, when in reality I only need one cell to be red or yellow to change the tab color. I'm sure this would be easier if I actually knew what I was doing, but I am just piecing together stuff I've searched for....
So whenever I play it, it changes the tab color to whatever color I have in the "Else" line.
Also, I will have multiple worksheets all doing the same thing and I don't want to have to run the code manually for every worksheet, I'd just want to hit F9 (I think F9) and have it run the code for all tabs, or preferably it will run whenever the file is opened.
Thanks for your help!
So whenever I play it, it changes the tab color to whatever color I have in the "Else" line.
Also, I will have multiple worksheets all doing the same thing and I don't want to have to run the code manually for every worksheet, I'd just want to hit F9 (I think F9) and have it run the code for all tabs, or preferably it will run whenever the file is opened.
Code:
Private Sub Worksheet_Calculate()
If Range("F3:F40").DisplayFormat.Interior.ColorIndex = 3 Then
Me.Tab.ColorIndex = 3 ' Red
End If
If Range("F3:F40").DisplayFormat.Interior.ColorIndex = 6 Then
Me.Tab.ColorIndex = 6 ' Yellow
Else
Me.Tab.ColorIndex = 45 ' Orange
End If
End Sub
Thanks for your help!