Changing tab color based on cell range colors

lisaOT

New Member
Joined
Oct 12, 2022
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Can anyone tell me exactly how to do this? I want to make the tab color change to yellow if any of the cells in column B on that tab are highlighted yellow. There are a few tabs on this worksheet and I want to apply the same thing to each tab, where the tab only highlights yellow if something in Column B is highlighted yellow, and if there is nothing yellow on the page, then the tab has no color or is white. I've tried some VBA modules, though I really don't know how to write them, nor understand them, and I am lost. I can insert them and make them work, but I have no idea how to write one for this. Can anyone help with one please?

1665589719099.png
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Can anyone tell me exactly how to do this? I want to make the tab color change to yellow if any of the cells in column B on that tab are highlighted yellow. There are a few tabs on this worksheet and I want to apply the same thing to each tab, where the tab only highlights yellow if something in Column B is highlighted yellow, and if there is nothing yellow on the page, then the tab has no color or is white. I've tried some VBA modules, though I really don't know how to write them, nor understand them, and I am lost. I can insert them and make them work, but I have no idea how to write one for this. Can anyone help with one please?

View attachment 76057
Start Up Order with check boxes unprotected with VBA.xlsm
ABCDEHI
1Computers
2ItemReceivedMissingComments
3Desktop Computer 1
4ChromeBooks 2
5
6
7
8
9
10
11
Computers
Cell Formulas
RangeFormula
E3E3=1-COUNTIF(F3,TRUE)
E4E4=2-COUNTIF(F4:G4,TRUE)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4Expression=$E$4>=1textNO
B3Expression=$E$3>=1textNO
E3:E4Cell Value>=1textNO
 
Upvote 0
Start Up Order with check boxes unprotected with VBA.xlsm
ABCDEHI
1Computers
2ItemReceivedMissingComments
3Desktop Computer 1
4ChromeBooks 2
5
6
7
8
9
10
11
Computers
Cell Formulas
RangeFormula
E3E3=1-COUNTIF(F3,TRUE)
E4E4=2-COUNTIF(F4:G4,TRUE)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4Expression=$E$4>=1textNO
B3Expression=$E$3>=1textNO
E3:E4Cell Value>=1textNO
C3, C4 & D4 each have check boxes in them that don't show on the mini-sheet, there are hidden rows that produce the true/false if the boxes are checked or not.
 
Upvote 0
First you should use one conditional formatting rule for all of column B, instead of one for each cell:

Applies to B:B
Excel Formula:
=$E1>=1

Same idea for column E.

Second, you should get rid of the merged cells in B1:H1. Use "Horizontal Center Across Selection"

Put this code into the module for this worksheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

   If Not Intersect(Target, Range("E:E")) Is Nothing Then
   
      If Application.WorksheetFunction.CountIf(Range("E:E"), ">1") > 0 Then
         Me.Tab.Color = RGB(255, 255, 0)
      Else
         With Me.Tab
            .ColorIndex = xlAutomatic
            .TintAndShade = 0
         End With
      End If
   
   End If

End Sub
 
Upvote 0
First you should use one conditional formatting rule for all of column B, instead of one for each cell:

Applies to B:B
Excel Formula:
=$E1>=1

Same idea for column E.

Second, you should get rid of the merged cells in B1:H1. Use "Horizontal Center Across Selection"

Put this code into the module for this worksheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

   If Not Intersect(Target, Range("E:E")) Is Nothing Then
  
      If Application.WorksheetFunction.CountIf(Range("E:E"), ">1") > 0 Then
         Me.Tab.Color = RGB(255, 255, 0)
      Else
         With Me.Tab
            .ColorIndex = xlAutomatic
            .TintAndShade = 0
         End With
      End If
  
   End If

End Sub
Thank you so much for your help!
When I changed the conditional format to your suggestion, it also fills in the cells with the words in the column Headings (row 2), and I want those to stay white. I tried giving them a white fill before the formatting and after, and neither try worked and they still change yellow. I tried the code anyway, with keeping the conditional format the same way, and it does not work, but most likely because I could not get the conditional format to work the way you wanted it. Any ideas?
 
Upvote 0
Start Up Order with check boxes unprotected.xlsx
ABCDEHI
1Computers
2ItemReceivedMissingComments
3Desktop Computer 1
4ChromeBooks 2
5
6
7
8
9
10
11
12
Computers
Cell Formulas
RangeFormula
E3E3=1-COUNTIF(F3,TRUE)
E4E4=2-COUNTIF(F4:G4,TRUE)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E3:E4Cell Value>=1textNO
B3:B4Expression=$E3>=1textNO



I've fixed a few things from the suggestions that @6StringJazzer made, and here is the updated sheet. A couple things did not work (see above response). Hoping someone can write a code for the module that might work for this one.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top