cell fill color spectrum

  • Thread starter Thread starter Matthew Dyer
  • Start date Start date
M

Matthew Dyer

I'm trying to make a sheet that shows all the possible cell fill
colors available in Excel. I'm using Excel 2002, SP3. The code I made
is as follows -

Sub colors()
Dim i As String
i = 1
a = 1
Do Until a = 65536
Rows(a).Interior.Color = i
i = i + 10
a = a + 1
Loop
End Sub

I switched the i loop to go up by 10 because I wasn't getting any good
variety in colors, only red black and maroon. Even after switching to
intervals of 10 I'm still only getting reds yellows and greens along
with blacks... I know there should be some blues and purples. Anyone
have any ideas?
 
Cell interior colors in XL2002 are limited to one of the 56-color
palette options.
If you try to use a color not in the palette it will just get mapped
(not sure exactly how) to the nearest match.

Tim
 
Cell interior colors in XL2002 are limited to one of the 56-color
palette options.
If you try to use a color not in the palette it will just get mapped
(not sure exactly how) to the nearest match.

Tim





- Show quoted text -

make's sense. So is there a way to code it so I can get all of the 55
possible colors to fill a cell with? (assuming 56th value is no fill
at all)
 
Hi Matthew
I did not create these code, they come from the newsgroups, just don't remember
from were.

Sub Allcolor()
Dim c As Integer
Dim j As Integer
For c = 0 To 5
For j = 0 To 9
If c * 10 + j < 57 Then
Cells(c + 12, j + 2).Interior.ColorIndex = c * 10 + j
Cells(c + 12, j + 2).Value = c * 10 + j
End If
Next j
Next c
End Sub
HTH
John
Cell interior colors in XL2002 are limited to one of the 56-color
palette options.
If you try to use a color not in the palette it will just get mapped
(not sure exactly how) to the nearest match.

Tim





- Show quoted text -

make's sense. So is there a way to code it so I can get all of the 55
possible colors to fill a cell with? (assuming 56th value is no fill
at all)
 
I would just fill the cells in a column from 1 to 56... that way the row
number would be the ColorIndex number...

Sub AllColors()
Dim X As Long
For X = 1 To 56
Cells(X, "A").Interior.ColorIndex = X
Next
End Sub

To the OP.... assign the predefined color index constant xlNone for the "no
color" option.
 
here's what i use, because it gives me hex values, too.


Sub Colors()
Dim ctr As Long

For ctr = 1 To 56
Cells(ctr, 1).Interior.ColorIndex = ctr
Cells(ctr, 2).Value = "'" & Right("000000" & _
Hex(ThisWorkbook.Colors(ctr)), 6)
Cells(ctr, 3).Value = ctr
Cells(ctr, 4).Value = Cells(ctr, 1).Interior.Color
Cells(ctr, 2).Font.Name = "Arial"
Cells(ctr, 2).HorizontalAlignment = xlRight
Cells(ctr, 3).HorizontalAlignment = xlCenter
Cells(ctr, 4).HorizontalAlignment = xlLeft
Next ctr

End Sub


--


Gary Keramidas
Excel 2003


Cell interior colors in XL2002 are limited to one of the 56-color
palette options.
If you try to use a color not in the palette it will just get mapped
(not sure exactly how) to the nearest match.

Tim





- Show quoted text -

make's sense. So is there a way to code it so I can get all of the 55
possible colors to fill a cell with? (assuming 56th value is no fill
at all)
 
Back
Top