Smoofinator
New Member
- Joined
- Feb 19, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
I need to automatically change the tab color to red if cell L3 contains "TRUE." I need this to run automatically on each sheet upon opening the file. I have used the code below, but I've had to add it to each sheet. Unfortunately, this doesn't run automatically and won't work unless I actually click into the cell and press enter. Plus, I have to attach this code to every freaking sheet (there are over 100) in the workbook! In summation, I need to open the file, auto run a check on each sheet for the value in L3, and if that value is TRUE, I need the tab color of that sheet to change to red. Any other values besides TRUE, the tab color doesn't change (no color).
Note: The TRUE and FALSE values in L3 are generated based on whether another cell's value is <0 or >0 (in other words, L3 isn't a simple text cell, but contains an "=if..." formula). Not sure if this matters, but wanted to mention.
Note: The TRUE and FALSE values in L3 are generated based on whether another cell's value is <0 or >0 (in other words, L3 isn't a simple text cell, but contains an "=if..." formula). Not sure if this matters, but wanted to mention.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
MyVal = Range("L3").Text
With ActiveSheet.Tab
Select Case MyVal
Case "TRUE"
.Color = vbRed
Case "FALSE"
.ColorIndex = xlColorIndexNone
Case Else
.ColorIndex = xlColorIndexNone
End Select
End With
End Sub