Worksheet tab color chart

VBAProIWish

Well-known Member
Joined
Jul 6, 2009
Messages
1,027
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have code here...

Code:
    Sheets("Cherry").Select
    ActiveSheet.Tab.Color = vbRed
and it works fine



But when I try to use the same code for "Grape" and "Purple", it doesn't work
Code:
    Sheets("Grapes").Select
    ActiveSheet.Tab.Color = vbPurple


Is there a color chart for all the worksheet tab colors that work?

For example, I know that VBRed, VBBlue, VBGreen work, but since purple doesn't work, it would be nice to have a more complete list.


Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Rather than using .color, you can use .colorindex.
If you use this code it will create a new workbook & paint the 1st 56 rows in the colours available
Code:
Sub PaintRows()

    Application.ScreenUpdating = False

    Workbooks.Add template:="Workbook"
    
    Range("a1").EntireColumn.Select
    With Selection
        .Font.Size = 14
        .Font.Name = "georgia"
    End With
    For i = 1 To 56
    Rows(i).Select
    With Selection
        .Interior.ColorIndex = i
        .RowHeight = 20
    End With
    Range("A" & i).Value = i
    Next i

    Application.ScreenUpdating = True

End Sub
 
Upvote 0
Try this:
1.Set any cell color to the color you like:
2. Click on the Fill color on the Menu Bar
3. Click on "MoreColors"
4. Click on "Custom"
5. You will now see the RGB colors and use these with my script.
6. Or Change the color in this window to what you want and use the RGB colors shown.

Code:
ActiveSheet.Tab.Color = RGB(185, 23, 255)
 
Upvote 0
Hello VBAProIWish,

Coloring should be a simple procedure but it isn't. Some objects like worksheet cells can only be colored using the 56 color palette. Unfortunately, the 56 colors are not standardized. They can be changed and even imported from other resources.

Other objects like the worksheet tab can use either the 56 color palette or the 24 bit RGB color scheme. Anyway here are the predefined color constants used in VBA ...

vbBlack
vbBlue
vbCyan
vbGreen
vbMagenta
vbRed
vbWhite
vbYellow
 
Upvote 0
This script will color your cells using RGB:
Code:
ActiveCell.Interior.Color = RGB(185, 255, 255)


Hello VBAProIWish,

Coloring should be a simple procedure but it isn't. Some objects like worksheet cells can only be colored using the 56 color palette. Unfortunately, the 56 colors are not standardized. They can be changed and even imported from other resources.

Other objects like the worksheet tab can use either the 56 color palette or the 24 bit RGB color scheme. Anyway here are the predefined color constants used in VBA ...

vbBlack
vbBlue
vbCyan
vbGreen
vbMagenta
vbRed
vbWhite
vbYellow
 
Upvote 0
Thanks MrKowz, but that didn't have any reference to "VBRed", "VBBlue", etc

Hi Fluff, I'm actually trying to change specific worksheet tab colors of the code you gave me.

I need a way to name the worksheet tabs 7 different colors

Red, Yellow, Green, Blue, Purple, Brown, Orange

From your previous code, I know that VBRed, VBGreen, VBBlue & VBYellow work, but I need "Purple", "Brown", "Orange" to work with something in "Laymen's terms".


In other words, I know that this kind of code will work...
Code:
    Sheets("MAIN").Select
    With ActiveWorkbook.Sheets("MAIN").Tab
        .color = 5287936
        .TintAndShade = 0
    End With

But, I don't know what color "5287936" is.


There must be a simpler way to...

1. Go to tab 1...
2. Color it Red
3. Go to tab 2...
4. Color it Yellow
5. Go to tab 3...
6. Color it "Green"

etc, etc,,,,

What is the easiest way to do this?

Thanks
 
Upvote 0
The easy way is to right click on the sheet tab choose tab color and set it to the color you want.
 
Upvote 0
My Aswer is This..

Yes, that is the easiest way...when not doing it through code of course.
Your earlier explanation was helpful though. Thanks


Leith,

This is very helpful, thank you!
 
Upvote 0
@VBAProIWish

I think I found something that might of interest to you - there exists a large list of constants in VBA which refer to colors. Open the Object Browser (F2) and under "Classes", scroll down and find "XlRgbColor". Click on this, and in the pane to the right of it, it will list a ton of color constants that you can use to set .Interior.Color on cells.

For example, I was just able to use Range("A1").Interior.Color = rgbPurple

Likewise, in the ObjectExplorer, there is a class called "ColorConstants" which will list all of the vbColors:

Code:
vbBlack
vbBlue
vbCyan
vbGreen
vbMagenta
vbRed
vbWhite
vbYellow

Hope this helps you out!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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