Does anyone know how to write the code to change the tab color of a worksheet if a True False Statement within that worksheet is False? I have Microsoft 2007. I would like the tab color to turn red if cell S21 is False and Green if cell S21 is True. If you need to know any other information let me know. Thanks!
Dim rngBool As Range, iColor As Integer
Set rngBool = ActiveSheet.Range("S21")
iColor = xlColorIndexNone
If rngBool.Value = "True" Then
iColor = 4
ElseIf rngBool.Value = "False" Then
iColor = 3
ActiveSheet.Tab.ColorIndex = iColor
Do I need to do edit any of this or should it just work if i cut and paste it into the view code when I right click the tab I want it for because I did that and it didn't work. Does the tab name need to be included? If so the tab name is "Program Analysis"
I posted a link in my last response, that should give you all the information you need. It's a pretty good tutorial. I pointed you directly where you find Sub and Function declarations, but it would behoove you to read through the whole thing... especially if you want to learn how to program macros in Excel.
This may sound simple, but have you tried theConditional Formating ->Highlights Cell Rules-> Text Containing..> write in TRUE and condition the cell fill as green...but then, this is simple, not sure whether I understood your goal.
I believe that is only for changing a cell color based on the formula. The goal is to have the conditional formating of the tab itself change colors depending on an if statement within that tab which is based on several other tabs within the workbook. Hopefully this helps.