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 the overview of the whole article.
Table of Contents hide
Download Practice Workbook
An Overview of GET.CELL Function
Introduction to Color Index and RGB Values
How to Find Color Index and RGB Values?
2 Effective Methods to Get Any Cell Color in Excel
1. Using GET.CELL Function to Get Cell Color in Excel
1.1. Showing Color Index of Left Cell
1.2. Showing Color Index of the Right Cell
2. Using VBA Codes to Get Cell Color in Excel
2.1. VBA Code to Get Cell Color Index
2.2. VBA Code to Get RGB Value of Cells
💬 Things to Remember
Conclusion
Related Articles
Download Practice Workbook
Download this practice workbook.
Get Cell Color.xlsm
An Overview of GET.CELL Function
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.
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.
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.
3. Click on Custom.
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:
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.
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))
5. Click on Ok.
6. Now, in Cell B5, type =Background
.
7. Then, press Enter.
As you can see, it is showing you the color index. Now, repeat the same thing for every cell.
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))
3. Now, in Cell E5, type =getLeftColor
.
4. Then, press Enter.
5. Finally, drag the Fill Handle icon over the range of cells E6:E12.
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))
3. Now, in Cell G5, type =getRightColor
.
4. Then, press Enter.
5. Finally, drag the Fill Handle icon over the range of cells G6:G12.
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.
3. Type the following code:
Function ColorIn(color As Range) As IntegerColorIn = color.Interior.ColorIndexEnd Function
4. Save the file.
5. Now, in Cell B5, type the following formula :
=ColorIn(B5)
6. Then, press Enter. It will show you the color index.
7. Finally, drag the Fill Handle icon over the range of cells B6:B12
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 VariantDim ColorValue As VariantColorValue = Cells(cell_range.Row, cell_range.Column).Interior.colorSelect Case LCase(Format)Case "rgb"FindColor = (ColorValue Mod 256) & ", " & ((ColorValue \ 256) Mod 256) & ", " & (ColorValue \ 65536)Case ElseFindColor = "Use'RGB' as second argument!"End SelectEnd Function
4. Save the file.
5. Now, in Cell B5, type the following formula :
=FindColor(B5,"rgb")
6. Then, press Enter. It will show you the color index.
7. Finally, drag the Fill Handle icon over the range of cells B6:B12
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
- Change the color of text and background of cells – An Excel Font and Fill Color Complete Guide
- How to Sort Data by Color in Excel (4 Criteria)
- 4 Quick Excel Formula to Change Cell Color Based On Date
FAQs
How do you reference a cell color in Excel formula? ›
=CELL("color",A1)
In this formula, "color" is a keyword that tells Excel to return the color code of the cell. A1 is the cell that you want to reference. You can replace A1 with any other cell reference in your workbook.
The COUNTIF function uses the named range (GetColor) as the criteria. The named range in the formula refers to the adjacent cell on the left (in column A) and returns the color code for that cell.
How do I color code in Excel based on comparison? ›- Input your data on an Excel spreadsheet. ...
- Select the data you want to color code. ...
- Navigate to Conditional Formatting. ...
- Select the color coding option you want to use. ...
- Apply rules for the conditional formatting.
- Select cell A2.
- click Conditional Formatting on the Home ribbon.
- click New Rule.
- click Use a formula to determine which cells to format.
- click into the formula box and enter the formula. ...
- click the Format button and select a red color.
Apply an If-Then rule to all cells by pressing “Ctrl-A” before assigning your rule. If you copy values from colored cells and paste them into new it new cells, the new cells acquire the color of the copied cell. You may find the “Text Contains” rule useful when working with alphanumeric data.
How to do a VLOOKUP based on cell color? ›Click Home > Conditional Formatting > Add New Rule.
In the New Formatting Rule dialog box, click Use a formula to determine which cells to format. Under Format values where this formula is true, type the formula: “=VLOOKUP(B3,$H$3:$I$10,2,FALSE) < D3” Click Format. In the Color box, select Red.
If Cell B2 = [the color red] then display FQS. If Cell B2 = [the color yellow] then display SM. This is conditional based on the cell fill color.
How to automatically color code cells in Excel based on value? ›On the Home tab, in the Styles group, click the arrow next to Conditional Formatting, and then click Color Scales. Select a three-color scale. The top color represents higher values, the center color represents middle values, and the bottom color represents lower values.
How do I conditional format color between two values in Excel? ›Example: Conditional Formatting if Between Two Values
To do so, highlight the values in the range B2:B14, then click the Conditional Formatting icon on the Home tab, then click Highlight Cells Rules, then Between: In the new window that appears, choose 10 as the lower value and 20 as the upper value: What is this?
The formula to compare two columns is =IF(A2=B2,”Match”,” ”). It returns the result as Match against the rows that contain matching values, and the remaining rows are left empty. To compare two columns in Excel for differences, replace the equals sign with the non-equality sign (<>).
How do you use multiple criteria in conditional formatting? ›
- Select the range to apply formatting rules.
- Click Home > Conditional Formatting > New Rule.
- Choose 'Use a formula to determine which cells to format', and type the formula: =AND(LEFT(F2,1)=” A”, RIGHT(F2,1)=” X”). ...
- Click on the Format button and add your preferred style.
On the Home tab, in the Styles group, click Conditional Formatting > New Rule… (see step 2 of How to dynamically change a cell color based on value for step-by-step guidance). In the "New Formatting Rule" dialog, select the option "Use a formula to determine which cells to format".
How do you color a cell based on another cell color? ›- Select the cells that you want to highlight. ...
- Click the format option in the tab.
- Click on the Conditional Formatting to open a new pane on the right.
- Select the single color tab.
- Hover over Format Rules and choose the “Custom formula if” option.
To conditionally format your data, you can utilize preset rules such as Color Scales, Data Bars and Icon Sets or create custom rules where you define when and how the selected cells should be highlighted.
Can you use an IF function to highlight a cell? ›Highlight Cells – IF Function
To highlight cells depending on the value contained in that cell with conditional formatting, you can use the IF Function within a Conditional Formatting rule. Select the range you want to apply formatting to. In the Ribbon, select Home > Conditional Formatting > New Rule.
To recap, the key differences between an XLOOKUP and a VLOOKUP are: XLOOKUP can look for values to the left and right of the lookup array, while VLOOKUP is limited to only looking for values to the right of the lookup value column.
Can you use Xlookup in conditional formatting? ›Using XLOOKUP in a Conditional Formatting statement in Excel 365 will not function as expected when the document is Exported/Downloaded as PDF.
How does Xlookup work in Excel? ›The XLOOKUP function searches a range or an array, and then returns the item corresponding to the first match it finds. If no match exists, then XLOOKUP can return the closest (approximate) match. *If omitted, XLOOKUP returns blank cells it finds in lookup_array.
How to automatically color code cells in sheets based on value? ›- On your computer, open a spreadsheet in Google Sheets.
- Select the cells you want to apply format rules to.
- Click Format. Conditional formatting. ...
- Create a rule. Single color: Under "Format cells if," choose the condition that you want to trigger the rule. ...
- Click Done.
You can conditionally highlight cells containing formulas in Excel by using the Conditional Formatting feature. To do this, first select the cells you want to format. Then, on the Home tab, in the Styles group, click Conditional Formatting. Next, click Highlight Cell Rules, and then click Contains Formulas.
How do I use dynamic conditional formatting? ›
- Select the range of cells to apply the conditional format. ...
- From the Excel menu, Select "Conditional Formatting" and then "New Rule..."
- Select "Use a formula to determine which cells to format".
To apply another conditional format to the cell, make sure the same cell is still selected and go through the above process again. You can add many conditional formats to the same cell and range in order to get the desired effect.
Can you conditional format based on color of another cell? ›Excel's predefined conditional formatting, such as Data Bars, Color Scales and Icon Sets, are mainly purposed to format cells based on their own values. If you want to apply conditional formatting based on another cell or format an entire row based on a single cell's value, then you will need to use formulas.
How do I compare two columns in Excel and highlight with color? ›To compare multiple columns in Excel, you can use the conditional formatting option on the home and format the setting to “duplicates” or “uniques”, and choose the desired color to highlight the values to compare multiple columns.
How to match data in Excel from 2 worksheets and highlight the differences? ›If you have more than two workbooks open, Excel displays the Compare Side by Side dialog box. In this dialog box, under Compare Side by Side with, click the workbook that contains the worksheet that you want to compare with your active worksheet, and then click OK.
How do you highlight cells if two conditions are met in Excel? ›Conditional Formatting With Multiple Conditions
To highlight cells according to multiple conditions being met, you can use the IF and AND Functions within a conditional formatting rule. Select the range you want to apply formatting to. In the Ribbon, select Home > Conditional Formatting > New Rule.
- Select the cells you want to apply conditional formatting to. Click the first cell in the range, and then drag to the last cell.
- Click HOME > Conditional Formatting > Highlight Cells Rules > Text that Contains. ...
- Select the color format for the text, and click OK.
- Select M2 (The cell at row 2 in column M)
- Home > Styles > Conditional Formatting > Manage Rules.
- New Rule.
- "Use a formula to determine which cells to format" (you probably have done it)
- This step is one of the key that you need to know. ...
- Apply the format you want.
- Using style.backgroundColor property.
- Using ClassList.add()
- Using setAttribute()
- Change background color of a div.
- Change background color dynamically on button click.
Dynamic Formulas allow you to insert Excel's formulas into cells even when the formula must reference rows that will be inserted later during the merge process. They can repeat for each inserted row or use only the cell where the field is placed.
Can I use an IF formula in conditional formatting? ›
Any conditional formatting argument must generate a TRUE result, meaning that at a literal level, your conditional formatting rule is an If/Then statement along the lines of “If this condition is TRUE, THEN format the cell this way”.
What are 2 types of conditional formatting in Excel? ›- Background Color Shading (of cells)
- Foreground Color Shading (of fonts)
- Data Bars.
- Icons (which have 4 different image types)
- Values.
Select the cells to be formatted. Click Conditional Formatting > Color Scales > More Rules. In the New Formatting Rule dialog box, configure these options: In the Format Style dropdown box, select either 2-Color Scale (default) or 3-Color Scale.
How to do custom formatting in Excel? ›- Select the cell or range of cells that you want to format.
- On the Home tab, under Number, on the Number Format pop-up menu. , click Custom.
- In the Format Cells dialog box, under Category, click Custom.
- At the bottom of the Type list, select the built-in format that you just created. ...
- Click OK.
Just select a cell with a formula you want to adjust and click the corresponding option from the Function by Color menu: Extensions > Function by Color > Edit selected formula. The add-on pane will open, featuring all settings that were used to build this formula.
How to make a cell turn a color in a formula in Excel based on date? ›To apply the formatting, you simply go to the Home tab > Conditional Formatting > Highlight Cell Rules and select A Date Occurring. Select one of the date options from the drop-down list in the left-hand part of the window, ranging from last month to next month.
How to change cell color in Excel based on text input with a formula? ›- Select the cells you want to apply conditional formatting to. Click the first cell in the range, and then drag to the last cell.
- Click HOME > Conditional Formatting > Highlight Cells Rules > Text that Contains. ...
- Select the color format for the text, and click OK.
In Google Sheets, conditional formatting allows you to dynamically change a cell's text style and background color based on custom rules you set. Every rule you set is created using an if this, then that statement.
How do you conditionally color cells in sheets? ›- On your computer, open a spreadsheet in Google Sheets.
- Select the cells you want to apply format rules to.
- Click Format. Conditional formatting. ...
- Create a rule. Single color: Under "Format cells if," choose the condition that you want to trigger the rule. ...
- Click Done.
In the Format Style dropdown box, select either 2-Color Scale (default) or 3-Color Scale. For Minimum, Midpoint and Maximum values, pick the data type (Number, Percent, Percentile, or Formula), and then choose the color.
How do I change cell color based on another cell color? ›
- Select the cells that you want to highlight. ...
- Click the format option in the tab.
- Click on the Conditional Formatting to open a new pane on the right.
- Select the single color tab.
- Hover over Format Rules and choose the “Custom formula if” option.
Click Home > Conditional Formatting > New Rule. In the Select a Rule Type box, click Use a formula to determine which cells to format. To apply color to alternate rows, in the Format values where this formula is true box, type the formula =MOD(ROW(),2)=0.
How do I change the active cell indicator color in Excel? ›Under Personal, click Appearance. On the Highlight color pop-up menu, click the color that you want. Note: You must close and then reopen Excel to see the new highlight color.
How do I automatically fill color in Excel? ›You can use Excel's AutoFill feature to fill the cell colors quickly. Simply drag the fill handle to the cells you want to fill and select the cell that contains the color you want to use. You'll be able to see the cells highlight as you drag. The color will fill the cells when you release the mouse button.