Changing Tab color based on the value from one cell

mlackey25

New Member
Joined
Apr 18, 2017
Messages
9
Hello, I have been trying to find the answer to this exact scenario for a few days and I cannot find anything that will work.

I am trying to change the color of the Tabs within a workbook that has 50+ worksheets.

The problem that I am running into is I want all the color to be based off multiple cells on the first sheet. For example, I have one cell on the first sheet that if the value = "Y" I want 6 tabs to change color or if the value = "N" I want 4 for the same tabs to change color. I am basically trying to make this an IF-THEN workbook that anyone could step in and use within my office. The "Y" and "N" are in a dropdown list but not a formula if that makes a difference.

All of the options that I can find, changes the color of the tab based on the value of the cell in the same worksheet. This will not really work for what I am trying to do without making a cell just "view" the value from the first page.

Any help is appreciated!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Mlackey25,

Code:
Sub colour()


    If Sheets("Sheet4").Range("A1").Value = 1 Then
    
    With ActiveWorkbook
        .Sheets("Products").Tab.Color = 255
        .Sheets("Sheet3").Tab.Color = 255
        .Sheets("Sheet4").Tab.Color = 255
    End With
    
    End If
End Sub

Are you looking for something similar to this?
It checks the if he value in sheet4 equals 1, if it does then it changes the tab colour of sheet 3, sheet 4 and a sheet named "products".

Best regards,
Mart
 
Upvote 0
Hey Mart,

This is what I am looking for, but I still cannot get it to change the colors of my tabs. I modified the code to fit my workbook but I am not sure what I did wrong. This is what I used. (I also doubled checked and I do have Macros turned on.)


Code:
Sub TabColor()    If Sheets("Start Here").Range("D47").Value = Y Then
    
    With ActiveWorkbook
        .Sheets("Cover").Tab.color = 255
        .Sheets("Cost Summary").Tab.color = 255
        .Sheets("Automated Mailroom Service").Tab.color = 255
    End With
    
    End If
End Sub
 
Upvote 0
Hi mlackey25,

As you are working with text the macro requires "Y" instead of just Y in the "If sheets...... = Y Then" line.
That should solve your problem.

Best regards,
Mart
 
Upvote 0
That is strange,

Is it giving an error? and, if so, on which line of code does the error occur?
 
Upvote 0
So strange thing is happening...

When I "F8" through the code it is working, but it will not work within the worksheet when I update the cell that it is looking at. It is also Case sensitive, is there a way to change that?
 
Upvote 0
I see, you want this code to run as soon as cell D47 in sheet "Start Here" is changed.

In that case we need to create a macro capable of identifying Events, we do so by putting the code under Sheet (Start Here) in the VBE.

Could you test this?
Code:
Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = "$D$47" Then
        If UCase(Sheets("Start Here").Range("D47").Value) = "Y" Then
            With ActiveWorkbook
                .Sheets("Cover").Tab.Color = 255
                .Sheets("Cost Summary").Tab.Color = 255
                .Sheets("Automated Mailroom Service").Tab.Color = 255
            End With
        End If
    End If


End Sub

I believe this will fit your needs.
 
Upvote 0
I am sorry that I did not make that clear at the beginning, I thought I had covered eveything.

I tried this, and I do not know if I am doing something wrong, but now I cannot get anything to work, I cannot even "F8" through the code in the VBE window. This code was meant to replace the prior, correct?
 
Upvote 0
Yes, it was supposed to replace the prior.

Where did you place the code? is it in a module within the modules folder in the VBE (on the left (In the project explorer window)) or is it in the sheet (Start Here) within the Microsoft Excel Objects folder (on the left (In the project explorer window)).
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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