Determining the precise color code in Excel is a valuable skill for anyone preparing reports or dashboards that require exact color matching across different platforms. Whether you are trying to align a chart's fill color with a company brand palette or ensure conditional formatting aditates perfectly with a design system, understanding how to extract the RGB or Hex value from a cell's interior is essential. While the interface does not display this data by default, the process is straightforward once you know where to look.

Using the Formula Bar Method

The most immediate way to find out the color code of a specific cell is through the formula bar, but this requires enabling the Analysis ToolPak add-in. This method provides you with the numerical RGB values, which are the foundational color definition for Excel objects. By inputting a specific function directly into a cell, you can convert the visual appearance of a cell into quantifiable data that can be reused elsewhere in your workbook.
Activating the Analysis ToolPak

Before you can use the color code formula, you must first activate the Analysis ToolPak, as it is not loaded by default in Excel. This add-in extends the software's capabilities, allowing for more advanced data analysis and, in this case, color extraction. The setup process is quick and only needs to be done once for your Excel application.
- Open the File tab and select Options.
- In the Excel Options window, choose Add-ins from the left-hand menu.
- At the bottom of the window, select Excel Add-ins from the manage dropdown and click Go.
- Check the box for Analysis ToolPak and click OK.

Entering the COLOR Functions
With the ToolPak enabled, you can now determine the color code in excel by inserting specific functions into an empty cell. You will need three separate formulas to extract the Red, Green, and Blue components of the fill color. These numbers can then be combined into a standard hex code if required for use in CSS or other design software.
- Red Value: Type
=GET.CELL(53, A1)into a cell, whereA1is the reference to the cell with the color. - Green Value: Use the formula
=GET.CELL(54, A1)to extract the green component. - Blue Value: Use the formula
=GET.CELL(55, A1)to extract the blue component.

VBA Macro for Direct Hex Output
For users who require the Hexadecimal color code directly, writing a simple VBA (Visual Basic for Applications) macro is the most efficient solution. This script bypasses the need to juggle multiple RGB function results and outputs the hex code in the familiar format used by web developers. It automates the extraction process, saving time if you need to audit multiple cells.
Accessing the VBA Editor

To utilize a macro, you first need to open the Visual Basic Editor where you can write and paste the code. This environment allows you to create custom functions that extend Excel's native functionality. Once the code is in place, you can call the function directly from any cell in your worksheet.
- Press ALT + F11 to open the VBA editor.
- Insert a new module via Insert → Module.
- Copy and paste the custom function code into the module window.




















Step-by-Step VBA Function Code
The following VBA function, named GetColorCode, loops through the rows of your worksheet to find the specific cell you are interested in. You simply input the cell address, and the function returns the Hex code. This provides a static value that will not change unless the macro is re-run, making it suitable for labeling and documentation.
Function GetColorCode(Cell As Range) As String
GetColorCode = "#" & Hex(Cell.Interior.Color)
End Function
|
Practical Application and Usage
After pasting the VBA code, you save the file as a macro-enabled workbook with the .xlsm extension. You can then use the new custom function in your worksheet just like any standard Excel formula. By typing the function with the target cell as the argument, you instantly retrieve the precise color identity. This is particularly useful for auditing a spreadsheet to ensure design consistency or reverse-engineering a template created by another user.
- In an empty cell, type
=GetColorCode(A1), replacingA1with the cell containing the color. - The cell will display the color code in Hex format, such as
#FF0000for red. - Format the result cell as text to ensure the hash symbol displays correctly.
Limitations and Important Notes
It is important to understand the distinction between fill color and font color when attempting to find out color code in excel. The methods described above specifically target the interior fill of the cell. If you are trying to identify the color of the text itself, you will need to modify the VBA script to target the font color property instead of the interior property. Furthermore, these color values are device-dependent RGB colors, meaning they may appear differently on various monitors or when printed compared to web-standard Hex colors.