ExcelRibbon.Tips.Net ExcelTips (Ribbon Interface)

Determining the RGB Value of a Color

Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining the RGB Value of a Color.

Neil uses colors a lot in his worksheets. He knows that he can generate a color based upon a numeric RGB value (and as explained in other ExcelTips issues). Neil would like to do the opposite—determine an RGB value. He wonders if there is a way to return (via function or macro) the RGB value of the color used to fill a cell.

Excel doesn't include a function to do this, but if you only need to check out the RGB values for a single cell, the easiest way is to follow these steps:

  1. Select the cell that is formatted with the color you want to check.
  2. Display the Home tab of the ribbon.
  3. Click the down-arrow at the right side of the Fill Color tool, in the Font group. Excel displays a small palette of colors and some other options.
  4. Choose More Colors. Excel displays the Colors dialog box.
  5. Make sure the Custom tab is displayed. (See Figure 1.)
  6. Figure 1. The Custom tab of the Colors dialog box.

  7. At the bottom of the dialog box you can see the individual values for the red, green, and blue components of the color in the cell.
  8. Click OK when done.

If you have a need to get the values more often, then creating your own user-defined function is the way to go. The function you use depends on what you want to actually have returned to your worksheet. For instance, if you want to have the traditional six-character hex code for RGB colors returned, you would use the following very simple macro:

Function getRGB1(rcell) As String
    Dim sColor As String

    sColor = Right("000000" & Hex(rcell.Interior.Color), 6)
    getRGB1 = Right(sColor, 2) & Mid(sColor, 3, 2) & Left(sColor, 2)
End Function

This macro looks at the interior color for any cell you reference, puts the hex values for the color in the right order, and returns the string to Excel. To use the function you simply invoke it, in your worksheet, with a cell referenced in this manner:


You may not want the traditional hex codes for the RGB colors, however. If you want to get the decimal values for each of the colors, then the following macro returns that:

Function getRGB2(rcell) As String
    Dim C As Long
    Dim R As Long
    Dim G As Long
    Dim B As Long

    C = rcell.Interior.Color
    R = C Mod 256
    G = C \ 256 Mod 256
    B = C \ 65536 Mod 256
    getRGB2 = "R=" & R & ", G=" & G & ", B=" & B
End Function

Invoked the same way as the getRGB1 macro, this version returns a string such as "R=255, G=204, B=0". You can also modify the macro even further so that it returns a single value, based upon a parameter you set:

Function getRGB3(rcell As Range, Optional opt As Integer) As Long
    Dim C As Long
    Dim R As Long
    Dim G As Long
    Dim B As Long

    C = rcell.Interior.Color
    R = C Mod 256
    G = C \ 256 Mod 256
    B = C \ 65536 Mod 256

    If opt = 1 Then
        getRGB3 = R
    ElseIf opt = 2 Then
        getRGB3 = G
    ElseIf opt = 3 Then
        getRGB3 = B
        getRGB3 = C
    End If
End Function

To use the macro, simply add a second parameter to the function used in your worksheet, specifying what you want:


If the second parameter is 1, then the function returns just the red value. If you specify a second parameter of 2, then the green value is returned, and 3 returns the blue value. Any other value for the second parameter (or if you omit it entirely) returns the full decimal value of the interior color.

If you don't want to go the route of creating a macro, or if you want to determine colors in more than just your Excel worksheet, you might consider a third-party utility. One that looks interesting is Instant Eyedropper, which is free. You can find more information about it here:


ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10180) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Determining the RGB Value of a Color.

Related Tips:

Step Up and Take Control! Subscribers to ExcelTips know just how valuable a resource it is. ExcelTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on ExcelTips archives and e-books. Check out ExcelTips Premium today!


Comments for this tip:

Dale    21 Apr 2014, 17:23

MS Word uses a .Color parameter for defining the color of hyperlinks.

Blue Hyperlink: .Color = -637468673
Purple Hyperlink: .Color = -620691457

Do you know how these values are determined from the standard RGB colors, where each color's values ranging from 0 - 255 in order to provide all of the intermediate hues ?

Thank you
Mawardi    05 Apr 2014, 10:37
Very helpful
Anyway, what if i want to set a cell color according to another cell value? Original cell used the value base on "getRGB3" and I want to change the target cell color than.
Willos    13 Mar 2014, 18:16
...or simply download the free program "GetColor!". It does all of that for you, and doesn't require any macros. I use it all the time.
Chuck Trese    13 Mar 2014, 10:33
Remember that the above tip will give you the cell's 'basic' or 'inherent' color format, but if the cell has conditional formatting applied, then the color you see may be different.
In addition, I have found that if the cell has no color applied to it, then the format dialog box will say the color is black (RGB = 0,0,0), but the cell will show as white (or, actually, whatever your background is, if you have set your background to a picture).
So, while the dialog box may tell you the color you have applied to the cell (or black, if you never applied any color to the cell), what you actually see may be 1)the color you set it to, 2)white, if no color is set, 3)a background color if no color is set but you have a background picture setting the color, or 4)the result of conditional formatting.
Irene    26 Aug 2013, 05:35
Thank you so much for explaining this :)
(as I used Conditional Formatting to add colour to the cell, I had to manage/edit the rule to find the colour -just a tip if you do not find the code as explained above ;) )
Dara Parsavand    10 Jun 2013, 18:21
For some reason this did not work for me until I went to a similar GUI via Control+1. Every time I clicked the Fill icon in the Font group, it would still show me RGB = 0 255 0 when the cell was in fact 153 255 153. But it worked great when I went to the GUI the other way (which looks a bit different, but the custom tab is still there). Strange.
Juli    24 Apr 2013, 15:10
I have, literally, searched Google for 2.5 days.
I receive a report where the status is a color fill designation, not a word or number value. I need to take these bi-weekly reports and input it into an Access DB for centralized storage. I have been wanting to use the Color Fill as the Status Unique ID in Access but couldn't figure out how to translate the status color to a unique value in Excel. These reports are literally thousands of lines.
This function will eventually add up to saving me hours & allow me to semi-automate the process. So, thank you.
sumit    02 Feb 2013, 06:02
it is really helpful tip. thanks alot..

Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 3+4? (To prevent automated submissions and spam.)
          Commenting Terms

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2014 Sharon Parq Associates, Inc.