Solved

Colour Excel ranges using HEX colours?

Posted on 2007-03-30
7
545 Views
Last Modified: 2008-01-09
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
Comment
Question by:TimHudspith
7 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 300 total points
ID: 18823971
Try this:
selection.interior.color = rgb(&H99, &HCC, &HFF)
and so on.
Regards,
Rory
0
 
LVL 15

Assisted Solution

by:dirknibleck
dirknibleck earned 150 total points
ID: 18823978
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
 

Author Comment

by:TimHudspith
ID: 18824149
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 85

Expert Comment

by:Rory Archibald
ID: 18824223
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
 
LVL 15

Assisted Solution

by:cquinn
cquinn earned 50 total points
ID: 18824224
Dim lColorVal as long

lColorval = Val("&H" & "99CCFF")
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 18824282
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
 
LVL 15

Expert Comment

by:dirknibleck
ID: 18824346
Rory's code snipet is converting the HEX for you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now