How to Get the 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.


Download Practice Workbook

Download this practice workbook.


The GET.CELL Function: an 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

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.


2 Effective Methods to Get Any Cell Color in Excel

In the next sections, 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 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 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 indexes. 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 are 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 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.


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. Don’t forget to check our website Exceldemy.com for various Excel-related problems and solutions.


Related Articles

Shanto

Hello! I am Shanto. An Excel & VBA Content Developer. My goal is to provide our readers with great tutorials on various Excel-related problems. I hope our easy but effective tutorials will enrich your knowledge. I have completed my BSc in Computer Science & Engineering from Daffodil International University. Working with data was always my passion. Love to work with data, analyze those, and find patterns. Also, love to research. Always look for challenges to keep me growing.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo