|
|
|
|
|
|
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:
|
- Copy the code above.
- Open Excel.
- Alt + F11 to open the Visual Basic Editor.
- Insert-Module.
- Paste the code into the code window at right.
- Close the VBE (Alt + Q or press the X in the top-right corner).
|
Test the code:
|
- Tools-Macro-Macros and double-click ColorIndex.
|
Sample File:
|
ColorIndex.ZIP 6.36KB
|
Approved by mdmackillop
|
This entry has been viewed 134 times.
|
|