View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Sub to list colorindexes and the corresponding fill colours

Sorry Max, muissed that function. Here it is

Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef blue)

red = colour And &HFF
green = colour \ 256 And &HFF
blue = colour \ 256 ^ 2 And &HFF

End Function


--
HTH

Bob Phillips

"Max" wrote in message
...
Thanks, Bob

Despite several tries at running your sub, I kept hitting:
Compile error: Sub or Function not defined

and "GetRGB" was highlighted in the line:
tmp = GetRGB(ActiveWorkbook.Colors(i), tRed, tGreen, tBlue)

What can I do ?

By fill colour, do you mean the RGB equivalent?

Actually, I'm afraid I don't know <g. Am new at this.

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Bob Phillips" wrote in message
...
Hi Max,



Public Sub Colours()
Dim i As Long
Dim tmp, tRed, tBlue, tGreen

For i = 1 To 56
Cells(i, "A").Value = i
Cells(i, "C").Interior.ColorIndex = i
tmp = GetRGB(ActiveWorkbook.Colors(i), tRed, tGreen, tBlue)
Cells(i, "B").Value = "RGB(" & tRed & ", " & tGreen & ", " &

tBlue
&
")"
Next i
Columns("B:B").AutoFit

End Sub