How to Get Cell Color in Excel (2 Methods)

While working with Excel, you can find colored cells. Sometimes, you may need to find a particular color of a cell. There are indexes and RGB values of any cell color. So, you may want to know the color index or RGB value. So that, you can use that in future. In this tutorial, we will show you how to get the color of any cell in Excel.


Overview

In the following image, you will find an overview of the whole article.

Overview to how to get cell color in Excel


GET.CELL Function in Excel: Overview

We are using GET.CELL to return more information about the worksheet setting than is achievable with the CELL function. We don’t need any VBA code here to implement this.

The Basic Syntax:

=GET.CELL(type_num, reference)

type_num is a number that specifies what type of cell information you want.

The following list shows the possible values of type_num and the corresponding results.

One problem is that you cannot use the GET.CELL directly in the worksheet.

The steps are as stated below:

1. Go to Formulas >Name Manager. A Name Manager dialog box will appear.

2. Then, click on New.

excel name manager dialog box

3. Give it any name.

4. In the Refers to box, type the following format:

=GET.CELL(63,INDIRECT("rc",FALSE))

As we are working with background colors, we are using 63 in the type_num argument.

excel get.cell function to get cell color

5. Finally, click OK.

Now, you can use the GET.CELL with the name that you have given.


Introduction to Color Index and RGB Values in Excel

Excel’s Color Palette has an index of 56 colors which you can use everywhere in your workbook. Each of these colors in the palette is connected with a unique value in the Color Index.

On the other hand, RGB (red, green, and blue) represents the colors on a computer display. We mix Red, green, and blue in various proportions to obtain any color in the visible color. The  R, G, and B values can range from 0 to 100 percent of full intensity. We represent it by the range of decimal numbers from 0 to 255 (256 levels for each color), equivalent to the range of binary numbers from 00000000 to 11111111, or hexadecimal 00 to FF. The total number of available colors is 256 x 256 x 256, or 16,777,216 possible colors.


How to Find Color Index and RGB Values?

We know there are 56 color indexes that you can use to format your cells. Now, this thing is tough to remember. To know more about Color Index, read more about Color Index Property.

On the other hand, you can find the RGB value of any color from Excel’s Home tab.

📌 Steps

1. First, go to the Home tab.

2. Then, click on the dropdown Fill Color > More Colors.

excel fill color in home tab

3. Click on Custom.

excel RGB colors

Here, you can find the RGB values of any color.


In the next section, we are providing you with two methods to implement in your dataset. The first one is using the GET.CELL method and the second one is using the VBA codes.

To demonstrate this tutorial, we are going to use this dataset:

dataset of excel get cell color

Here, we have some colors in different cells. We will find those colors indexes and RGB values using these two methods.


1. Using GET.CELL Function to Get Cell Color in Excel

Now, we have already discussed the GET.CELL function earlier in this article. We are going to use it in our dataset.

📌 Steps

1. First, go to the Formula tab. Click on Name Manager. A Name Manager dialog box will appear.

2. Click on New.

excel name manager to get cell color

3. Now, give it a name. We are using it as Background.

4. In the Refers to box, type the following formula:

=GET.CELL(63,INDIRECT("rc",FALSE))

get.cell function in name manager box

5. Click on OK.

6. Now, in Cell B5, type =Background

type Background in the cell to get color

7. Then, press Enter.

result of the Get.cell function in excel

As you can see, it is showing you the color index. Now, repeat the same thing for every cell.

excel get cell color


1.1. Showing Color Index of Left Cell

Now, the method above was to show the color in the colored cell. If you want to show the color index in left cells then follow the steps below:

📌 Steps

1. Go to the Name Manager again. Give this the name “getLeftColor”.

2. In the Refers to box, type the following formula:

=GET.CELL(63,INDIRECT("rc[-1]",FALSE))

name manager dialog box

type the get.cell function

3. Now, in Cell E5, type =getLeftColor

type formula in cell to get color in excel

4. Then, press Enter.

result after typing the formula

5. Finally, drag the Fill Handle icon over the range of cells E6:E12.

drag fill handle icon to get color

As you can see, we have successfully found the color of the cell in another cell.


1.2. Showing Color Index of the Right Cell

If you want to show the color index in the right cells then follow the steps below:

📌Steps

1. Go to the Name Manager again. Give this the name “getRightColor”.

2. In the Refers to box, type the following formula:

=GET.CELL(63,INDIRECT("rc[1]",FALSE))

name manager dialog box

type get.cell function to get color

3. Now, in Cell G5, type =getRightColor

type the formula to get color

4. Then, press Enter.

result after typing the formula

5. Finally, drag the Fill Handle icon over the range of cells G6:G12.

final result of excel get cell color

As you can see, we have successfully found the color of the cell in another cell.

Limitation to Use the GET.CELL Function:

If you change the color of the cell, the value won’t change. To solve this, press F9 on your keyboard to recalculate it again.


2. Using VBA Codes to Get Cell Color in Excel

If you know Excel’s VBA codes, this method will seem too easy for you. There are two VBA codes that you can use in your dataset. The first one is for indexes. The second one is for the RGB values.


2.1. VBA Code to Get Cell Color Index

Now, this method might not give you exact indexes like the previous one. But you can consider it as an index. I hope it will come in handy.

📌 Steps

1. First, press Alt+F11 on your keyboard to open the VBA editor.

2. Next, click on Insert > Module.

insert module of VBA editor

3. Type the following code:

Function ColorIn(color As Range) As Integer
ColorIn = color.Interior.ColorIndex
End Function

4. Save the file.

5. Now, in Cell B5, type the following formula :

=ColorIn(B5)

type the formula in the cell

6. Then, press Enter. It will show you the color index.

result of the VBA code to get color

7. Finally, drag the Fill Handle icon over the range of cells B6:B12.

drag the fill handle to copy the formula

As you can see, we were successful in getting the color of the cell in Excel.


2.2. VBA Code to Get RGB Value of Cells

This method will help you find the RGB value of the cell. This method is more efficient than the previous one.

📌 Steps

1. First, press Alt+F11 on your keyboard to open the VBA editor.

2. Next, click on Insert > Module.

3. Type the following code:

Function FindColor(cell_range As Range, ByVal Format As String) As Variant
Dim ColorValue As Variant
ColorValue = Cells(cell_range.Row, cell_range.Column).Interior.color
Select Case LCase(Format)
Case "rgb"
FindColor = (ColorValue Mod 256) & ", " & ((ColorValue \ 256) Mod 256) & ", " & (ColorValue \ 65536)
Case Else
FindColor = "Use'RGB' as second argument!"
End Select
End Function

4. Save the file.

5. Now, in Cell B5, type the following formula :

=FindColor(B5,"rgb")

type formula to get color

6. Then, press Enter. It will show you the color index.

result of the VBA code

7. Finally, drag the Fill Handle icon over the range of cells B6:B12.

final result of excel get cell color

In the end, you will see the RGB values of all the cells.


💬 Things to Remember

✎  RGB values are the most used. In our opinion, you should always try to find RGB values.

✎  The color index doesn’t change after changing the cell color. Press F9 to recalculate.


Download Practice Workbook

Download this practice workbook.


Conclusion

To conclude, I hope this tutorial will help you to get the cell color in Excel. We recommend you learn and apply all these methods to your dataset. Download the practice workbook and try these yourself. Also, feel free to give feedback in the comment section. Your valuable feedback keeps us motivated to create tutorials like this.


Excel Get Cell Color: Knowledge Hub


<< Go Back to Excel Cell FormatLearn Excel

Get FREE Advanced Excel Exercises with Solutions!
A.N.M. Mohaimen Shanto
A.N.M. Mohaimen Shanto

A.N.M. Mohaimen Shanto, a B.Sc. in Computer Science and Engineering from Daffodil International University, boasts two years of experience as a Project Manager at Exceldemy. He authored 90+ articles and led teams as a Team Leader, meticulously reviewing over a thousand articles. Currently, he focuses on enhancing article quality. His passion lies in Excel VBA, Data Science, and SEO, where he enjoys simplifying complex ideas to facilitate learning and growth. His journey mirrors Exceldemy's dedication to excellence and... Read Full Bio

19 Comments
  1. i rarely saw such bad explanations, i don’t understand anything

    for instance, in the downloaded excel file, i cannot see nowhere the function GET.CELL
    ????

    • Hi Blump,
      We do use Microsoft 365 version to make our documents. If you use older versions of Excel, you may not find it.
      By the way, thanks for your feedback.
      Thanks.

  2. Hi, good post thanks. I have formatted cells by conditional not manual work, could it be possible to get this background color??

    • I’m listening!!! 🙂
      I really hope there is a way to extract the color information of a conditional formatted cell.

      • To extract color information of conditional formatting cells, you need to follow the steps

        1. First, use the conditional formattings in your dataset.
        2. Then, click on the Dialog Box Launcher (Small tilted arrow beside Clipboard) from the Clipboard group.
        3. After that, click on Clear All from there.
        4. Copy the conditionally formatted range.
        5. Now, select a new cell where you want to paste your conditional formatting range color only.
        6. After that, click on Paste All from the Clipboard group.
        7. Now, remove the numbers and only remains the conditional formatting colors.
        8. Now, use =Background or =getLeftColor or =getRightColor just like this article, you will get your desired color information.

        Try this solution I think you will get your desired result. If you face any more problems, inform us.

  3. Hello Mark SIMONS and GVG,
    Can you please share your Excel dataset with us? Then, we will try our best to provide you with the required solution.

  4. If you have the Indirect address to another file in a cell to the left, you can use this formula instead: =GET.CELL(63,INDIRECT(INDIRECT(“RC[-1]”,FALSE),TRUE))
    The indirect address would be ‘[fileName.xlsm]sheetName’!$A$1

    • Hello, DANIEL DUMITRU!
      Thanks for your comment. Appreciate your efforts. Stay connected with us!
      Good Luck!

      Regards,
      Sabrina Ayon
      Author, ExcelDemy
      .

  5. Brilliant!

    Very useful!

    Thank you!

  6. Unfortunately this didn’t work. It just shows the formula, not the number

    • Hello, STEVE C.
      Thank you for sharing your problem with us. All the methods shown in the article should work perfectly for Microsoft 365 version. You might be using an older version. That’s why you are facing the problem. So, make sure to activate Microsoft 365 on your PC. Then, you should be able to use these procedures to get the color index.
      Do let us know if your problem is solved or not.
      Regards,
      Sourav Kundu
      ExcelDemy

  7. It does not work!
    I inserted the VBA script you mention for Index.
    Saved the file as excel with macros.
    inserted the formula ColorIn(B5) as instructed.
    No matter what color I use, it always shows -4142 as a result

    • Reply Lutfor Rahman Shimanto
      Lutfor Rahman Shimanto Feb 22, 2024 at 6:20 PM

      Hello Miriam,

      Thank you for sharing your problem with us. We are sorry you’re experiencing issues with the Excel VBA script for getting cell color.

      Here are a few steps you can take to address the problem:

      1. First, to get your desired results, ensure you’re using Microsoft 365. Activate it on your PC to use the given methods for obtaining color indexes.
      2. Then, follow the below steps to Check Macro Security Settings:
        • Make sure that your Excel settings allow the execution of macros. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and ensure that “Enable all macros” or “Enable all macros with notification” is selected.

      Please let us know if your problem is solved or not.

      Regards,
      Bishawajit Chakraborty
      ExcelDemy

  8. It does not work with color information of conditional formatting cells, The reply from DURJOY PAUL is not clear, especially step 7

    • Reply Lutfor Rahman Shimanto
      Lutfor Rahman Shimanto Mar 7, 2024 at 2:38 PM

      Hello SHIQIANG

      Thanks for sharing your problem. Typically, we are unable to perform such tasks in Excel. However, you can try using an Excel VBA Sub-procedure I have developed. It will display all the color indexes of the selected cells in the Immediate Window. The idea works perfectly if background is set manually or only one conditional formatting rule is applied in a cell. You can easily modify the formula for multiple conditional formatting rules based on your needs.

      OUTPUT Overview:

      Excel VBA Code:

      
      Sub GetConditionalFormattingColor()
      
          Dim cell As Range
          Dim colorIndex As Variant
      
          For Each cell In Selection
              If cell.FormatConditions.Count > 0 And cell.Value <> "" Then
                  colorIndex = cell.FormatConditions(1).Interior.colorIndex
                  Debug.Print "Background color index for cell " & cell.Address & ": " & colorIndex
              Else
                  colorIndex = cell.Interior.colorIndex
                  
                  If colorIndex = -4142 Then
                      Debug.Print "Currently, the Cell " & cell.Address & " does not have any color."
                  Else
                      Debug.Print "Background color index for cell " & cell.Address & ": " & colorIndex
                  End If
      
              End If
          Next cell
          
      End Sub
      

      Reach out again if you have any further queries. Hopefully, the idea will help you; good luck.

      Regards
      Lutfor Rahman Shimanto
      Excel & VBA Developer
      ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo