Excel VBA Color Index List – Worksheet Interior Font – Colour Codes

Excel VBA Color Index List

Excel color index are used to change either a worksheet’s background(Interior), font or border color.

There are 56 colors that has predefined color index in Excel. These base codes are present in the Excel Color palette. To get the absolute VBA color code for any colour that we have chosen (datatype: long) from palette, we have to use interior color property.

This can be referred & used in a VBA code as explained in below code snippets.

Excel VBA Color Index Table

You can create Excel Colorindex table using this VBA code. If you are trying to convert the VBA color code to different format, then check this site.

The below code can be used to create a Color index table, get Color index of a cell background, border or font and also to set the color.

Execute the above code by pressing F5 on a new workbook.

Predefined Names For VBA Color Index List

In VBA code, there 8 color constants that are predefined. They are listed below.

  1. vbBlack
  2. vbBlue
  3. vbCyan
  4. vbGreen
  5. vbMagenda
  6. vbRed
  7. vbWhite
  8. vbYellow

These values hold the long (decimal) value corresponding to VBA color index. In case if you want more color constants, then use the color codes defined under ‘XlRgbColor’ collection.

Instead of using numbers inside code, this way of naming the colors will be more meaningful to the programmers. It is easy to understand.

Get Complete List of Color Code Names

If you want to see a complete list of predefined names for colors, then go to Excel Vb editor, press F2 to get ‘Object browser.

You can find a search box in this object browser. Type “Colorconstants” or “xlrgb color” & press enter.

This will give you complete list of predefined colors. Inside any vba code, you can just use these names instead of worrying about color codes.

Excel VBA Color Index Predefined Names
Excel VBA Color Index Predefined Names

Similar to this, you can view ‘colorconstants’ starting with vb (like vbgreen, vbred etc.,)

Change Worksheet Tab Color

We an also set a background color for each worksheet name Tabs in Excel. At the left bottom of Worksheet, you an see different Tabs with worksheet names present in the active Excel workbook.

Using the below code, the Worksheet tab color can be set or modified.

Once F5 key is pressed, the above code executes & changes the Tab colors. This will be easy to color code tabs for easy identification.