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
http://dmcritchie.mvps.org/excel/colors.htm

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

but I'm doing something wrong!
Help!
brothertruffle880Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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 SpecialistCommented:
Convert your colour here
https://www.shodor.org/stella2java/rgbint.html

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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 SpecialistCommented:
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
VBA

From novice to tech pro — start learning today.