• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

Colour Excel ranges using HEX colours?

I want to use a wider range of colours on my Excel spreadsheet than is available from the standard palette.

I've found a website devoted to colour combinations for graphic designers - which is ideal - but all the colours are expressed as HEX:
99CCFF - a light blue
FFCC00 - dirty yellow
99CC99 - grey/green

Using VBA, how can I set the range.interior.color property to these colours?
0
TimHudspith
Asked:
TimHudspith
3 Solutions
 
Rory ArchibaldCommented:
Try this:
selection.interior.color = rgb(&H99, &HCC, &HFF)
and so on.
Regards,
Rory
0
 
dirknibleckCommented:
From Excel Help:

Interior.Color =  RGB(0, 255, 0)

HEX codes are RGB colors. If the HEX code is 112233, take 11 and convert to decimal, this is R. Take 22 and convert to decimal, this is G. Take 33 and convert to decimal, this is B.

Thus Interior.Color = RGB(R,G,B)
0
 
TimHudspithAuthor Commented:
rorya - It gives me colours but it's hit and miss: some are exactly the same as shown on the website but those that are blue / grey shades just come out as light grey.  Is this some Excel limitation?

dirknibleck - how do I convert HEX to decimal?
 
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Rory ArchibaldCommented:
It seems that for interior you are limited to 56 colours, no matter what you do. The only way round that is to upgrade to XL2007.
0
 
cquinnCommented:
Dim lColorVal as long

lColorval = Val("&H" & "99CCFF")
0
 
Rory ArchibaldCommented:
Essentially, Excel will give you the closest match from the colour palette to the colour you are trying to apply. You can change the colours on the palette to match your RGB values, but you can still only have 56 at a time.
HTH
Rory
0
 
dirknibleckCommented:
Rory's code snipet is converting the HEX for you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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