Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Sub to list colorindexes and the corresponding fill colours

Hi Max,

By fill colour, do you mean the RGB equivalent?

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

--
HTH

Bob Phillips

"Max" wrote in message
...
Hi guys,

(Apologies for the earlier post w/o any subject line)

I'm looking for a sub which can list all the colorindexes down say col A,
and all the corresponding fill colors in col B ?

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----




  #2   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to list colorindexes and the corresponding fill colours

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sub to list colorindexes and the corresponding fill colours

Bob forgot to furnish this function to go along with the code:

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




--

Regards,

Tom Ogilvy



"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





  #4   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to list colorindexes and the corresponding fill colours

"Tom Ogilvy" wrote
Bob forgot to furnish this function to go along with the code:
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


Thanks, Tom (again) !
Yes, that did it here, too !
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #5   Report Post  
Posted to microsoft.public.excel.programming
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







  #6   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to list colorindexes and the corresponding fill colours

"Bob Phillips" wrote
Sorry Max, muissed that function. Here it is ...

It's ok, Bob. Got the missing piece from Tom just now
Thanks for the response !
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill & Font colours have dissapeared Ferd Excel Discussion (Misc queries) 1 October 23rd 07 09:43 PM
TWO DIFFERENT FILL COLOURs ON MENU BAR Kirstoff Excel Discussion (Misc queries) 2 August 17th 07 04:30 PM
Cell Fill colours stuart Excel Discussion (Misc queries) 2 March 8th 07 05:04 PM
fill colours Khyber Setting up and Configuration of Excel 8 August 22nd 06 01:32 AM
Fill colours Theo Excel Worksheet Functions 1 January 13th 06 04:16 AM


All times are GMT +1. The time now is 03:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"