Excel: Match Web Colors with HEX2DEC

This page is an advertiser-supported excerpt of the book, Power Excel 2010-2013 from MrExcel - 567 Excel Mysteries Solved. If you like this topic, please consider buying the entire e-book.


Problem: I need my Excel document to match the colors on our website. I can tell from the HTML that the Web background is #FF9007. How can I match this in Excel?

Strategy: The colors specified in HTML are hexadecimal numbers. This numbering system has 16 digits, from 0 through 9 and A through F. Your Excel document uses RGB (Red, Green, Blue) values, which are decimal. You can use the HEX2DEC function to convert each pair of hex digits to decimal. Here's what you do:

  1. In three cells, enter each pair of digits from the color code. Enter an apostrophe before 07 to keep the leading zero.
  2. Enter a formula of =HEX2DEC(B2). Excel will convert the FF to 255. This is the red value for the color in Excel.
  3. Copy the function to the other two cells. The second value is the green value. The third value is the Blue value.
  4. Select the area to be formatted.
  5. Choose Home, Paint Bucket dropdown and choose More Colors. On the Custom tab of the Colors dialog, choose 255 for Red, 144 for Green, 7 for Blue. Click OK.

  1. Use =HEX2DEC to convert the Web colors to RGB.

    Additional Details: To convert RGB values to hexadecimal, you use DEC2HEX.

    Historically, Excel offered functions to convert between Binary, Octal, Decimal, and Hexadecimal. Excel 2013 introduces two new flexible functions that handle all numbering systems from Binary (Base 2) to Base 36. To convert from a number in Base 16 to Decimal, use =DECIMAL("œB2",16). To convert from decimal 144 to Hexadecimal, use =BASE(144,16).


For more resources for Microsoft Excel