Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Excel 2010 VBA - Color Ranges for cell backgrounds and fonts

When I use a command:
activecell.font.color = 5300000

my font turns green.

Question:  
1.  How many colors are available in this numbering system (I know it's in the millions)?
2.  Is there a palette of colors that show the approximate value of these numbers?
0
brothertruffle880
Asked:
brothertruffle880
  • 2
2 Solutions
 
BenefordCommented:
These colors are RGB, with 8 bits for each color, so 0-255 giving 16777216 colours in all.

For convenience, we often write them in hexadecimal

5300000 = 0x50df20 - which means 0x50 Blue, 0xDF Green, 0x20 Red.

Just construct the number from the colours you need.

There's a useful list of colors listed here:
http://cloford.com/resources/colours/namedcol.htm (use the column named 'access').
0
 
brothertruffle880Author Commented:
Are you saying that you can code the color in VBA using hex?

If so, can you give an example?
0
 
BenefordCommented:
Prefix the hex number with &H:

    ActiveCell.Font.Color = &HFF207f

will set the colour to Blue=0xFF, Green=0x20, Red=0x7f
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now