Retrieve Excel Cell's Font & Fill RGB Color Code

Discover & Find Excel Cell's Font & Fill RGB Color Code

What This Does

Appearance can play a huge factor in the professionalism of your spreadsheet's presentation.  Often there are times when I want to match a specific color that falls outside the current spreadsheet's Theme Color palette.  There are also times when I want to match an Excel color so I can use it inside another program (ie Photoshop, Ribbet, etc...).  The best way to guarantee you are using the exact same color is to find that specific color's color code.  There are two ways to do this: manually or macro-matically (yeah, I just invented that word). Since I'm such a nice guy, I'm going to walk you through how to do both! Enjoy :)

Manual Way To Find RGB Color Code

  1. Select a cell that contains the fill color you want to lookup
  2. Click the Paint Bucket button on your Home Ribbon tab
  3. Select the More Colors option
  4. Go to the Custom tab and make sure Color Model = RGB
  5. You will now see the RGB color code for your selected cell's fill

This method can be performed similarly for cell font & border colors.  The only step you will need to change from above is step #2.

Now With VBA Code

Below I've posted VBA code that determines the color code.  These macros can easily be pasted into your Personal Macro file if you think you will use it often.

Figuring Out The Fill Color

Sub GetRGBColor_Fill()
'PURPOSE: Output the RGB color code for the ActiveCell's Fill Color
'SOURCE: www.TheSpreadsheetGuru.com

Dim HEXcolor As String
Dim RGBcolor As String

HEXcolor = Right("000000" & Hex(ActiveCell.Interior.Color), 6)

RGBcolor = "RGB (" & CInt("&H" & Right(HEXcolor, 2)) & _
", " & CInt("&H" & Mid(HEXcolor, 3, 2)) & _
", " & CInt("&H" & Left(HEXcolor, 2)) & ")"

MsgBox RGBcolor, vbInformation, "Cell " & ActiveCell.Address(False, False) & ":  Fill Color"

End Sub

Figuring Out The Font Color

Sub GetRGBColor_Font()
'PURPOSE: Output the RGB color code for the ActiveCell's Font Color
'SOURCE: www.TheSpreadsheetGuru.com

Dim HEXcolor As String
Dim RGBcolor As String

HEXcolor = Right("000000" & Hex(ActiveCell.Font.Color), 6)

RGBcolor = "RGB (" & CInt("&H" & Right(HEXcolor, 2)) & _
", " & CInt("&H" & Mid(HEXcolor, 3, 2)) & _
", " & CInt("&H" & Left(HEXcolor, 2)) & ")"

MsgBox RGBcolor, vbInformation, "Cell " & ActiveCell.Address(False, False) & ":  Font Color"

End Sub

How Do I Modify This To Fit My Specific Needs?

Chances are this post did not give you the exact answer you were looking for. We all have different situations and it's impossible to account for every particular need one might have. That's why I want to share with you: My Guide to Getting the Solution to your Problems FAST! In this article, I explain the best strategies I have come up with over the years to getting quick answers to complex problems in Excel, PowerPoint, VBA, you name it

I highly recommend that you check this guide out before asking me or anyone else in the comments section to solve your specific problem. I can guarantee 9 times out of 10, one of my strategies will get you the answer(s) you are needing faster than it will take me to get back to you with a possible solution. I try my best to help everyone out, but sometimes I don't have time to fit everyone's questions in (there never seem to be quite enough hours in the day!).

I wish you the best of luck and I hope this tutorial gets you heading in the right direction!

Chris "Macro" Newman :)