Interior Cell Color Numbers

C

Charlotte E.

They range from 0 to 55.

If you want to see what color correspond to what number, just create a small
macro to do so :)


CE
 
J

Jim Thomlinson

XL stores 56 colours (0 - 55). obviously your computer has more than 56
colours but that is the maximum number of colours that XL can keep track of.
By default XL starts off with a stock pallette, but you are free to change
those colours if you wish. So while we could give you a listing of the stock
colours if you have changed any of the colours then all bets are off.

Here is a mocro that you can run to get a listing of the current colours...

Sub ColourList()
Dim rng As Range
Dim lng As Long

Set rng = Range("A1")
For lng = 0 To 55
rng.Value = lng
rng.Offset(0, 1).Interior.ColorIndex = lng
Set rng = rng.Offset(1, 0)
Next lng
End Sub
 
M

Mike

Thanks Jim

Jim Thomlinson said:
XL stores 56 colours (0 - 55). obviously your computer has more than 56
colours but that is the maximum number of colours that XL can keep track of.
By default XL starts off with a stock pallette, but you are free to change
those colours if you wish. So while we could give you a listing of the stock
colours if you have changed any of the colours then all bets are off.

Here is a mocro that you can run to get a listing of the current colours...

Sub ColourList()
Dim rng As Range
Dim lng As Long

Set rng = Range("A1")
For lng = 0 To 55
rng.Value = lng
rng.Offset(0, 1).Interior.ColorIndex = lng
Set rng = rng.Offset(1, 0)
Next lng
End Sub
 
X

xlmate

Excel Help doesn't provide this, 40 color palette is on a toolbar icon, and
56 color palette is available with Format, Cells, Patterns(tab)

run this macro to generate 56 colors and its related constants on a worksheet

Sub ColorValue()

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)

For i = 1 To 14
objExcel.Cells(i, 1).Value = i
objExcel.Cells(i, 2).Interior.ColorIndex = i
Next

For i = 15 To 28
objExcel.Cells(i - 14, 3).Value = i
objExcel.Cells(i - 14, 4).Interior.ColorIndex = i
Next

For i = 29 To 42
objExcel.Cells(i - 28, 5).Value = i
objExcel.Cells(i - 28, 6).Interior.ColorIndex = i
Next

For i = 43 To 56
objExcel.Cells(i - 42, 7).Value = i
objExcel.Cells(i - 42, 8).Interior.ColorIndex = i
Next

End Sub

Hope this help. Pls click Yes if this help

cheers
 
P

Peter T

XL stores 56 colours (0 - 55).

The index of the first colour in the palette is 1, so colours 1 - 56

Regards,
Peter T
 
C

Chip Pearson

To create a list of colors, use code like

Sub ListColors()
Dim N As Long
For N = 1 To 56
Cells(N, 1).Interior.ColorIndex = N
Cells(N, 2).Value = N
Cells(N, 3).Value = Hex(ThisWorkbook.Colors(N))
Next N
End Sub

Column A will be colored with ColorIndex N, where N is the row number.
Column B will have the value N, and C will have the hex value of the
color.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
J

Jim Thomlinson

Could be... How is it every other language starts counting at 0 and VB starts
at 0 somethimes and 1 sometimes... Man is that annoying... Thanks for
catching that.
 
C

Chip Pearson

As I'm sure you know, VBA/VB Classic allows you to use any bounds
(including negative) you want, as long as LBound <= UBound. The Option
Base compiler directive allows you to set the default LBound to either
0 or 1 for arrays that do not specify an LBound (a bad practice, in my
opinion -- you should always specify an LBound).

VB.NET, though, conforms to other programming languages and requires
an LBound of 0.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
J

JLGWhiz

Or you can simply open the VBE and look for PatternColorIndex Property in the
help file. It has the color palette displayed with the corresponding numbers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top