Excel 2013 VBA - How to use hex digits to color the interior of a cell.

How can I use hex digits to color the interior of a cell.
I'm trying to use this chart

using this syntax
Range("c1:c20").Interior.Color = &H222222

but I'm doing something wrong!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KoenChange and Transition ManagerCommented:
and what are you doing wrong?
your code turns cells C1 to C2 in black... (at least in my excel)... Is that not what you want?
Wayne Taylor (webtubbs)Commented:
'&H222222' isn't a Hex colour code. What colour are you after?
Shaun VermaakTechnical Specialist/DeveloperCommented:
Convert your colour here

The above should look like this
Range("c1:c20").Interior.Color = 2236962

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Gustav BrockCIOCommented:
You need to convert that value.

In my article - on a slightly higher level topic - found here:
Create Windows Phone Colour Palette and Selector using WithEvents

go to the paragraph Extras near the bottom and locate the second code block with the function RGBCompound.
That's the one for you to use:

Range("C1:C20").Interior.Color = RGBCompound("222222")

Open in new window

Shaun VermaakTechnical Specialist/DeveloperCommented:
You do not "need" to convert that value. The function only makes it more user-friendly to use HEX colour values. If you record a macro and change the colour you will see that it will work just fine with integer colour value.
brothertruffle880Author Commented:
Thanks everyone!  Great insights on using that option.
I feel like I took a college class in color.
Gustav BrockCIOCommented:
You are welcome!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

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.