Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Bring up Color Palette to select color | Excel Discussion (Misc queries) | |||
Changing text case in entire database column from JOHN to John | Excel Discussion (Misc queries) | |||
how to format Doe,John to Doe, John (space after a comma) | Excel Worksheet Functions | |||
John Walkenbach Color Palette | Excel Programming | |||
John Walkenbach Colour Palette | Excel Programming |