Passing Back Color to Interior Color

E

ExcelMonkey

I have a routine that passes the back colour of a button
to the interior colour of a range called Comrng. The
colour the button takes on is based on a routine. When
the button is coloured(by routine), the routine works
fine. However, when I have it set up using its default
grey (&H8000000F&) colour, teh Comrng takes the valu of 0
and diplays a black interior color.

When it is woking, the immediate window shows:
?CellComColBtn.BackColor
16764057
?Comrng.Offset(-1, 0).Interior.Color
16764057
When its not it shows:
?CellComColBtn.BackColor
-2147483633
?Comrng.Offset(-1, 0).Interior.Color
0

What is going on here?????

If ComChkBx = True Then
Set Comrng = .Worksheets(AuditShtName).Range
(PasteStartCell).Offset(0, ChkbxArray(0, 1) * 2 - 2)
Comrng.Offset(-1, 0) = "Cell Comments"
Comrng.Offset(-1, 0).Interior.Color =
CellComColBtn.BackColor
End If
 
T

Tom Ogilvy

That's because your working with apples and oranges.

The default gray color of the button is only gray because those are your
windows settings. the number (&H8000000F&) is not an RGB color - it is a
code designating the button should take on the system color defined for
Button Face. If you go to the desktop, select properties and assign a
different color for button face, then show your form, it should take on this
new color, but still have the value (&H8000000F&) . You can set a button
to a specific color using RGB. Then it would return the RGB in that case
(the 16764057 in your example)

the cells are using RGB colors, so when you feed this value to it, it
converts it to an RGB color.

the max RGB color is:
? &HFFFFFF
16777215
your color number is bigger than that, so you can use an if test to
determine that the value is or isn't and RGB color value and adjust from
there.

You can see this by going into the properties window of the button and
looking at the backcolor property. the initial choices are system colors
(on the system tab). You can select the palette tab and assign an RGB
color.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top