Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Colour Excel ranges using HEX colours?

Posted on 2007-03-30
7
Medium Priority
?
563 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 900 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 450 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 150 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

610 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