Excel

List All Colors and Their Index Numbers in a Workbook

Ease of Use

Easy

Version tested with

2002 

Submitted by:

Jacob Hilderbrand

Description:

This macro lists all the available Excel color index numbers in a workbook in Column A and its corresponding index number in Column B. 

Discussion:

Color indexes are used in VBA code, but it is hard to remember all of them. What is the index for red, blue, yellow? This macro displays all the colors and their index numbers so you can easily choose. 

Code:

instructions for use

			

Option Explicit Sub ColorIndex() Dim x As Long For x = 1 To 56 Range("A" & x).Interior.ColorIndex = x Range("B" & x).Value = x Next x End Sub

How to use:

  1. Copy the code above.
  2. Open Excel.
  3. Alt + F11 to open the Visual Basic Editor.
  4. Insert-Module.
  5. Paste the code into the code window at right.
  6. Close the VBE (Alt + Q or press the X in the top-right corner).
 

Test the code:

  1. Tools-Macro-Macros and double-click ColorIndex.
 

Sample File:

ColorIndex.ZIP 6.36KB 

Approved by mdmackillop


This entry has been viewed 134 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express