RGB Using VBA

  • Thread starter Thread starter June
  • Start date Start date
J

June

How do I use th valid range for a normal RGB color, i.e. 0 to 16,777,215
(&H00FFFFFF) to format a cell using VBA.

Your help is appreciated!
 
Hi June,
Excel is limited to 56 colors (colorindex colors), you can
specify colors using RGB, but Excel will try to match the
color you specify to one of the 56 colors in your color
palette. You would be much better choosing your color via
the colorindex. More information on Colors in
Color Palette and the 56 Excel ColorIndex Colors
http://www.mvps.org/dmcritchie/excel/colors.htm

Selection.Interior.Color = RGB(200, 250, 200)
Selection.Interior.Color = &Hc8efac8

but you would be better off selecting a colorindex yourself
Selection.Interior.ColorIndex = 35 ' RGB(204,255,204)
as they don't always work out close to what you want.
 

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

Back
Top