To convert HEX to RGB in Excel, use =HEX2DEC(MID(A2,1,2)), =HEX2DEC(MID(A2,3,2)), and =HEX2DEC(MID(A2,5,2)) to return red, green, and blue bytes from a hashless six-digit value in cell A2.

Each formula extracts one two-character hex pair and converts it to a decimal channel byte. These values are suitable for worksheet calculations, Excel VBA color properties, chart formatting, and documentation that requires separate RGB components.

The positions above assume a canonical six-digit value without a leading hash. If cell A2 contains #RRGGBB, change the starting positions to 2, 4, and 6, or remove the hash before running the formulas. Excel’s HEX2DEC function expects hexadecimal digits, not the CSS hash symbol.

convert hex to rgb in excel
Convert HEX to RGB in Excel: Formulas and Steps

Convert a HEX Cell into RGB Columns

This workflow creates separate red, green, blue, and optional alpha columns from a canonical CSS hex value.

  1. Prepare cell A2. Format cell A2 as Text before pasting a six-digit value such as RRGGBB without the leading # or surrounding spaces. Otherwise, Excel may coerce an all-numeric value with leading zeros, such as 003366, to 3366 and shift the MID results. For a translucent color, use the CSS order RRGGBBAA and keep the alpha pair last.
  2. Extract red in B2. Enter =HEX2DEC(MID(A2,1,2)). The first pair becomes a decimal value from 0 to 255.
  3. Extract green in C2. Enter =HEX2DEC(MID(A2,3,2)). This reads the second pair rather than reusing the red value.
  4. Extract blue in D2. Enter =HEX2DEC(MID(A2,5,2)). The third pair completes the RGB channel set.
  5. Add alpha when present. For a hashless eight-digit value in A2, enter =HEX2DEC(MID(A2,7,2)) in E2. If you need opacity as a fraction, enter =E2/255 in F2.
  6. Fill the formulas down. Select B2:F2, copy the formulas, and paste them beside the remaining source values. Use the alpha column only for inputs that actually specify transparency.

Worked example: With 336699 in A2, the substitutions are =HEX2DEC("33") = 51, =HEX2DEC("66") = 102, and =HEX2DEC("99") = 153, so the RGB result is 51, 102, 153.

If you only need a CSS-compatible reference beside the numbers, you can build an rgb() string with ="rgb("&B2&", "&C2&", "&D2&")". This creates display text for a worksheet; it is not the same format that Excel VBA expects for a cell fill.

Match Excel Formulas to the HEX Layout

Formula positions depend on whether the source includes a hash and whether it contains an alpha pair. The following table compares the layouts supported by the workflow.

Cell A2 containsRedGreenBlueAlpha byte
Six digits, no hash=HEX2DEC(MID(A2,1,2))=HEX2DEC(MID(A2,3,2))=HEX2DEC(MID(A2,5,2))Not specified
Six digits with a hash=HEX2DEC(MID(A2,2,2))=HEX2DEC(MID(A2,4,2))=HEX2DEC(MID(A2,6,2))Not specified
Eight digits, no hash=HEX2DEC(MID(A2,1,2))=HEX2DEC(MID(A2,3,2))=HEX2DEC(MID(A2,5,2))=HEX2DEC(MID(A2,7,2))
Eight digits with a hash=HEX2DEC(MID(A2,2,2))=HEX2DEC(MID(A2,4,2))=HEX2DEC(MID(A2,6,2))=HEX2DEC(MID(A2,8,2))
Three or four digitsNormalize firstNormalize firstNormalize firstNormalize first

The four CSS forms are defined in the W3C CSS hexadecimal notation. Short forms cannot be read safely with a single pair of MID positions because each original digit expands into two characters. Normalize them before applying the table’s formulas.

Use the Channels in Excel Formatting

Excel VBA’s built-in RGB function accepts three numeric channel arguments and returns the numeric color value used by Excel properties. It is not the same as a CSS rgb() string, so insert the extracted values as arguments rather than pasting VBA’s numeric result into a stylesheet.

  1. Open the VBA editor. Press Alt+F11 in Excel, then choose Insert and Module.
  2. Enter a small macro. Use Sub SetCellColor(), then Range("A1").Interior.Color = RGB(51, 102, 153), followed by End Sub. The numbers here continue the worked example above.
  3. Run and test it. Place the cursor inside the macro and press F5. Replace the three arguments with the values from your own worksheet when testing another color.

Cell fills, shapes, and chart elements can expose different color properties, so check the target object’s available controls rather than assuming every Excel object accepts the same syntax. The classic VBA RGB function also does not turn a separate alpha byte into a CSS rgba() declaration. Keep alpha as its own value unless a specific target API documents how it expects transparency.

Normalize Strict CSS HEX in the Browser

The HEX to RGB Converter is useful when the source is a complete CSS hex token rather than a canonical value ready for Excel formulas. It accepts #RGB, #RGBA, #RRGGBB, and #RRGGBBAA, including uppercase or lowercase letters.

  1. Paste the complete CSS color. Include the required leading # and use three, four, six, or eight hexadecimal digits.
  2. Read the normalized output. Review the expanded lowercase HEX, CSS rgb() or rgba() value, and separate red, green, blue, and alpha bytes before moving them into Excel.
  3. Check the preview and retain exact transparency. For a translucent color, keep the alpha byte or normalized eight-digit HEX when a rounded decimal alpha could reduce round-trip precision.

The parser trims ordinary whitespace around the complete value but rejects a missing hash, doubled hash, embedded spaces, incorrect lengths, and characters outside 0–9 and A–F. Short values are expanded by duplicating each digit rather than guessed. An invalid or empty entry replaces the previous conversion with a clear error, preventing a stale result from being mistaken for the current input.

Processing, validation, formatting, and preview rendering happen locally in the current browser, and the color string is not uploaded to Lizely. The tool follows CSS hexadecimal notation rather than every shorthand a design application might tolerate. It does not parse named colors, hsl(), lab(), lch(), color(), CSS variables, gradients, or palettes.

Handle Alpha Without Changing Channel Order

Four- and eight-digit CSS values include transparency, while three- and six-digit values omit alpha and are treated as fully opaque for the preview. In an eight-digit CSS value, the order is red, green, blue, then alpha. The alpha byte is the final pair, not the first pair.

The converter exposes the alpha as an integer byte from 0 to 255 and calculates opacity by dividing that byte by 255. Its readable rgba() output uses up to three decimal places, but the exact byte and normalized HEX remain visible. Retain one of those exact forms for APIs, test fixtures, design tokens, or round trips where a small rounding difference matters. The Convert Hexadecimal to RGB Channel Bytes and Alpha reference explains the channel structure in more detail.

Do not rearrange an eight-digit CSS value into alpha-first order. The converter does not interpret #AARRGGBB as CSS and will not reorder an input based on how it appears. Verify the source convention before separating its components for Excel.

Choose the Right Output and Verify the Result

OutputBest usePrecision or interpretation note
RGB channel bytesExcel formulas, VBA, APIs, canvas work, and test fixturesExact integers from 0 to 255
CSS rgb() or rgba()Stylesheets and CSS documentationReadable alpha may be rounded; the exact byte remains available
Normalized lowercase HEXDesign tokens and exact color round tripsBest form for preserving an eight-digit translucent value
Live color previewQuick channel-order and visual sanity checkNot a color-management or print-proof reference
  • Confirm the source syntax. Check the hash, digit count, and absence of embedded spaces before conversion.
  • Confirm channel order. Red comes first, green second, and blue third in both CSS and the Excel formulas shown here.
  • Confirm transparency separately. Use the final pair of a CSS eight-digit value and compare its exact byte with the target application.
  • Compare numbers, not just appearance. Screens, browser profiles, brightness, ambient light, and wide-gamut workflows can make the same sRGB value look different.

For an Excel workflow, the most dependable result combines three independently checked channel values with the normalized HEX retained in a reference column. That makes it easy to detect a parsing mistake and preserves the original CSS color without depending on rounded alpha text or screen appearance alone.

If you're weighing options, How Do I Compare Two Ways to Convert CMYK to RGB? covers this in detail.