Information on color matching

rdionne

New Member
Joined
Feb 21, 2002
Messages
47
I don't know if this would be useful to anyone, but I had to find out how to match the background color of controls on my spreadsheet to the sheet's fill color and here's what I learned about the color format:

Making background color values of controls match the spreadsheet fill color.

1. Fill spreadsheet with color of your choice from indexed colors
2. Find out which index color it is
?ActiveWorkbook.ActiveSheet.Range("a1").interior.colorindex
=33
3. Find out the long decimal value for the color
?activeworkbook.Colors(33)
=16763904
4. Convert the decimal number to hex using the windows calculator app.
=FFCC00
5. Add padding byte 00 to start of the hex number
=00FFCC00
6. Add VB hex signifier &H before and & after the number
7. Paste the value into the background property of the controls on the worksheet.

Number format: &H00000000&
^^
padding

Colors are entered as BGR order not RGB

RGB to long hex conversion:

Color RGB(0,204,255)

Dec Hex
Red 0 00
Green 204 CC
Blue 255 FF

Result: &H00FFCC00&
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Please excuse the formatting problem of my post. The tabs didn't show up correctly.
I suppose a person could also alter a color in the pallete to match the control's background color.
 
Upvote 0
Thanks for sharing this. One thing (To save you one step), instead of ColorIndex use Color, like this:

Range("A1").Interior.Color

which would return the Long value of the color.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top