View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
EricG EricG is offline
external usenet poster
 
Posts: 220
Default Cell Shading Colour Property

Here's a manual way to get all the color names in the default color pallet
for Excel 2003:

Draw a rectangle on a sheet and double-click it to bring up the format dialog.
Click on the Fill color drop-down so that all the fill colors show up.
Hover the pointer over each color swatch until the color name comes up.

Now all you have to do is associate each color swatch with its color index,
which is an exercise that I will leave to the reader. Well, maybe not - you
can get the color index of each swatch by recording a macro in which you draw
that rectangle, and then set its color to each of the fill colors in the
pallet. You will then have a list of the color index values.

HTH,

Eric


"Tim Childs" wrote:

Hi

The first function gives a cell's shading colour-index property and the
second converts it to a description. Has anyone the list of indexes and a
colour description so I no longer need the Else statement near the end. I
wnated to cover the basic colours in the Format cells tab, 40+ I suppose

Thanks

Tim

PS hope the US colleagues will forgive "colour" variant spelling :)

Function ShowColourIndexNo(Cell As Object) As Integer
ShowColourIndexNo = Cell.Interior.ColorIndex
End Function

Function ConvertColorIndexToText(Cell As Object) As String
Dim Temp As Variant

Select Case Cell.Value
Case -4142
Temp = "No colour"
Case 3
Temp = "Bright red"
Case 4
Temp = "Bright green"
Case 5
Temp = "Dark blue"
Case 34
Temp = "Light blue"
Case 35
Temp = "Light green"
Case Else
Temp = "Non-specified"
End Select

ConvertColorIndexToText = Temp

End Function