Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default John Walkenbach Color Palette (Repost)

This is a repost. I posted this yesterday but did not describe it properly.

I am using the JW color palette. I am using it to do the following:

1) Pass a color from palette to the backcolor property of a button on a
userform
2) test to see if font color in specific cell matches backcolor property of
button

Firstly, when I call up the palette, most colors pass correctly to the
button on the userform. However the top left color (Black) will not pass to
the form. When I drag the cursor over the color black, the JW form tells me
that its RGB color is:

0 0 0

Why will this not turn the button black?

Secondly, in situations where the color passes correctly to the button, the
test to see if font color = button back color fails. For example, when I
pass red to the button (RGB(255,0,0)), the button turns red. However my test
for red font does not seem to work. The procedure is:

Public Function CellFontHasColour(rng As Range)
If rng.Font.Color = FontColorColBtn.BackColor Then
CellFontHasColour = True
End If
End Function

Yet in my immediate window I get:
?rng.Font.Color
255

?FontColorColBtn.BackColor
12632256

My font is clearly red as illustratd by the 255. Yet my BackColor property
of the button which I clearly passed red to now says 12632256.

I must admit I am really struggling with the whole colour issue in VBA.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default John Walkenbach Color Palette (Repost)

I don't know why your button's backcolor isn't behaving but this code, which
shows how to convert a Color value to its RGB constituents might help your
debugging:

Sub ReturnRGB()
Dim r As Byte, g As Byte, b As Byte
Dim x As Long
x = 12632256
LongToRGB x, r, g, b
MsgBox "r = " & r & Chr(10) & "g = " & g & Chr(10) & "b = " & b
End Sub

Sub LongToRGB(lColor As Long, r As Byte, g As Byte, b As Byte)
r = CByte(lColor And &HFF&)
g = CByte((lColor And &HFF00&) \ &HFF&)
b = CByte((lColor And &HFF0000) \ &HFFFF&)
End Sub


--
Jim
"ExcelMonkey" wrote in message
...
| This is a repost. I posted this yesterday but did not describe it
properly.
|
| I am using the JW color palette. I am using it to do the following:
|
| 1) Pass a color from palette to the backcolor property of a button on a
| userform
| 2) test to see if font color in specific cell matches backcolor property
of
| button
|
| Firstly, when I call up the palette, most colors pass correctly to the
| button on the userform. However the top left color (Black) will not pass
to
| the form. When I drag the cursor over the color black, the JW form tells
me
| that its RGB color is:
|
| 0 0 0
|
| Why will this not turn the button black?
|
| Secondly, in situations where the color passes correctly to the button,
the
| test to see if font color = button back color fails. For example, when I
| pass red to the button (RGB(255,0,0)), the button turns red. However my
test
| for red font does not seem to work. The procedure is:
|
| Public Function CellFontHasColour(rng As Range)
| If rng.Font.Color = FontColorColBtn.BackColor Then
| CellFontHasColour = True
| End If
| End Function
|
| Yet in my immediate window I get:
| ?rng.Font.Color
| 255
|
| ?FontColorColBtn.BackColor
| 12632256
|
| My font is clearly red as illustratd by the 255. Yet my BackColor
property
| of the button which I clearly passed red to now says 12632256.
|
| I must admit I am really struggling with the whole colour issue in VBA.
|
| Thanks


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
Bring up Color Palette to select color pokdbz Excel Discussion (Misc queries) 4 August 6th 07 10:13 PM
Changing text case in entire database column from JOHN to John Kimberly in Palm Springs Excel Discussion (Misc queries) 2 October 10th 06 06:26 PM
how to format Doe,John to Doe, John (space after a comma) asuncionw Excel Worksheet Functions 8 November 4th 05 01:56 PM
John Walkenbach Color Palette ExcelMonkey Excel Programming 0 July 14th 05 04:17 PM
John Walkenbach Colour Palette ExcelMonkey[_190_] Excel Programming 1 March 20th 05 07:23 PM


All times are GMT +1. The time now is 04:09 AM.

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

About Us

"It's about Microsoft Excel"