How Do I Get Hex Color Code in Excel: Easy Step-by-Step Guide

Stephen Jul 12, 2026

Finding the exact hex color code in Excel is a common need when you are building dashboards or preparing reports that must match specific brand guidelines. This process becomes straightforward once you understand how Excel stores and displays color data internally. Many users struggle because the interface does not show the hex value directly in the familiar color picker dialog.

the color chart for hex code is shown in blue, green, yellow and pink
the color chart for hex code is shown in blue, green, yellow and pink

Unlike modern design tools that display the hex code upfront, Excel relies on an underlying system of color indices and RGB values. You can bridge this gap by either using a manual formula to convert the color index or by accessing the Visual Basic for Applications editor to extract the precise code. This guide will walk you through multiple reliable methods that work across different versions of Microsoft Excel.

All the Hex Codes for Colors You Need to Succeed Online | LouiseM
All the Hex Codes for Colors You Need to Succeed Online | LouiseM

Using the Get Excel Cell Color Code Add In

The easiest way to get hex color code in Excel is to install a dedicated add-in specifically designed for this task. These tools integrate directly into your ribbon and provide a live preview of the hex value as you hover over cells. This method saves time and eliminates the need to write complex formulas or open the Visual Basic Editor.

Pick Colors from Any Image – Free HEX, RGB & Color Codes
Pick Colors from Any Image – Free HEX, RGB & Color Codes

Most add-ins are lightweight and install in minutes, requiring just a few clicks to load into your Excel environment. Once installed, they often include features to export the color palette or standardize colors across an entire workbook. Look for add-ins that are compatible with your version of Excel and have positive user reviews regarding stability.

Manual Installation Steps

100+ Trending Canva Color Palette Hex Codes 🎨
100+ Trending Canva Color Palette Hex Codes 🎨

To use an add-in, you usually need to download the .xlam or .xll file from a trusted source. Navigate to the Developer tab in Excel, click on Excel Add-ins, and then browse to select the file you saved locally. After enabling the macro settings, the new custom functions or buttons will appear on your toolbar for immediate use.

Always ensure the source is reputable to avoid security risks, especially when dealing with macros that modify your workbook structure. Once activated, you can simply select a cell with the desired color and click the add-in button to display the hex code instantly in a message box or adjacent cell.

Applying a Custom VBA Function

How to get the HTML color codes in Google Sheets - Plus every color in the color picker!
How to get the HTML color codes in Google Sheets - Plus every color in the color picker!

For users comfortable with programming, writing a small VBA function is an excellent way to get hex color code in Excel without external tools. This method gives you full control over the logic and allows you to modify the output format to suit your specific needs. The function works by reading the interior color of a cell and converting its RGB components into a standard hash string.

VBA code can be added to the Visual Basic Editor by pressing Alt + F11, inserting a new module, and pasting the function code. This approach is highly efficient if you need to perform this action repeatedly or integrate the color extraction into larger automated reporting solutions.

Writing the Function

goodnotes pen & highlighter hex codes β™‘
goodnotes pen & highlighter hex codes β™‘

To create the function, you define a Public Sub that takes a range as an input and outputs a string representing the hex value. The code typically uses the RGB function to retrieve the red, green, and blue components and then formats them as two-digit hexadecimal numbers. Converting decimal to hex requires using the Hex function and ensuring the result is padded with a leading zero if necessary to maintain the six-character format.

Here is a common example of such a function: you loop through the cells in the selection, retrieve the RGB values, and concatenate them into a string like "#RRGGBB". This allows you to type a simple formula in any cell, such as "=CellColorHex(A1)", to instantly see the code for the background color of cell A1.

color palettes with hex codes
color palettes with hex codes
an image of different colors and numbers on a white background with the words color code below it
an image of different colors and numbers on a white background with the words color code below it
How To Determine Hex Color Codes For VBA Userforms
How To Determine Hex Color Codes For VBA Userforms
Hex codes
Hex codes
TOOL TIP TUESDAY:  2013-2014 RGB & HEX Color Code Charts...
TOOL TIP TUESDAY: 2013-2014 RGB & HEX Color Code Charts...
100-SUPER-TIPS-HEX hosted at ImgBB
100-SUPER-TIPS-HEX hosted at ImgBB
Hex Color Palette
Hex Color Palette
Color-Coded Drop-Down Lists in Excel – Make Data Entry Smarter
Color-Coded Drop-Down Lists in Excel – Make Data Entry Smarter
the color chart for different shades of pastel and neutrals, with text below
the color chart for different shades of pastel and neutrals, with text below
Organized & Aesthetic: Color Codes for Google Sheets in Every Shade🌟
Organized & Aesthetic: Color Codes for Google Sheets in Every Shade🌟
Generate a Complete Colour Palette From One Hex Code: Free for Designers
Generate a Complete Colour Palette From One Hex Code: Free for Designers
Hex Colors dark purple Pink
Hex Colors dark purple Pink
an info sheet with different font and numbers on it, including the names of each type
an info sheet with different font and numbers on it, including the names of each type
PROGRESS color palette – BNG witth shadow CODES hex
PROGRESS color palette – BNG witth shadow CODES hex
Hex Codes
Hex Codes
Summer Color Palette Hex Codes
Summer Color Palette Hex Codes
My Fave Hex Codes
My Fave Hex Codes
Summer Pastel Color Names & Hex Codes Cheat Sheet
Summer Pastel Color Names & Hex Codes Cheat Sheet
Procreate Color Creator
Procreate Color Creator
DTI hex Codes!! ( luv them)
DTI hex Codes!! ( luv them)

Running the Macro Securely

Because VBA projects can contain executable code, Excel will prompt you to enable macros when you open the workbook containing the function. You should only enable macros if the file comes from a trusted source and you understand the security implications. Once enabled, the custom function behaves like any standard worksheet formula, making it very user-friendly for end-users.

Keep in mind that saving the file as a macro-free format like .xlsx will strip the VBA code, so you must save the workbook as a macro-enabled file, typically with the .xlsm extension. This ensures the function remains available for future editing and sharing within your team.

Reading Color Index Values Manually

If you only need a quick lookup and do not want to use VBA, you can rely on Excel's built-in color index system. Every cell background color is associated with an index number that corresponds to a specific shade in the standard palette. You can see this index number by opening the Format Cells dialog and checking the Fill tab.

However, the index number does not directly give you the hex value, so you will need to cross-reference it with a color index chart. These charts map the index numbers to their standard RGB and hex equivalents, which is sufficient for the limited palette of the legacy Excel color system. This method is practical for ensuring consistency with older templates that use indexed colors rather than full RGB definitions.

Using Conditional Logic to Simulate Conversion

Advanced users can create a lookup table on a separate sheet that lists all 56 color index numbers and their corresponding hex codes. By using a combination of the CELL function to retrieve the color index and the VLOOKUP function to find the matching hex value, you can build a formula-driven solution. This avoids the need for macros while still providing accurate results for standard colors.

The main limitation of this approach is that it does not support custom RGB colors created through the color mixer in the formatting dialog. For those specific cases, you must rely on the VBA method or the add-in method to extract the precise hex code generated by the full RGB spectrum.

Extracting RGB Values for Web Use

Another path to obtain hex color code in Excel involves first isolating the individual RGB components and then converting them manually. You can use the GET.CELL function in a named range to pull the red, green, and blue values from a target cell's interior color. This technique is powerful because it breaks down the color into its fundamental parts, which are required for the final hex conversion.

Setting up the named formulas requires some care in the Name Manager, where you define the references to the red, green, and blue values based on the active cell. Once the named ranges are working, you can create temporary cells that display the decimal values of each color channel, which serve as the building blocks for the hex string.

Concatenating the Hex String

With the RGB decimal values available, you convert each number to hexadecimal using the DEC2HEX function. It is critical to wrap each result with the TEXT function to force a two-digit output, ensuring that values like 15 appear as "0F" instead of just "F". You then concatenate the three pairs of hex digits with a leading "#" symbol to form the final code that is used in CSS and HTML.

This manual method is educational and helps users understand the relationship between Excel colors and web standards. While it is more involved than using an add-in, it provides a reliable fallback when macros are disabled or when you need to audit the color logic yourself.

Mastering these techniques ensures you can handle any color matching task directly within your spreadsheets, improving accuracy and workflow efficiency. As you become more familiar with the tools available, you will find it easy to maintain brand consistency and integrate Excel data seamlessly with web design projects.