DEC2HEX Function in Excel: Decimal to Hexadecimal

DEC2HEX Function in Excel: Decimal to Hexadecimal featured illustration

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 min readUpdated 28 September 2026

EngineeringLevel: IntermediateAvailable in: Excel 2007+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. DEC2HEX in practice
  5. Where you will use it
  6. Worked example
  7. Mistakes people make
  8. Related functions
  9. Continue learning

DEC2HEX converts numbers to hex β€” the notation behind web colours and memory addresses.

Advertisement

Syntax

=DEC2HEX(number, [places])
Argument What it means
places Pad with leading zeros.

Examples

Example 1

="#"&DEC2HEX(A2,2)&DEC2HEX(B2,2)&DEC2HEX(C2,2)

RGB 255, 128, 0 becomes #FF8000.

DEC2HEX in practice

Where you will use it

  • Colour codes for charts and HTML
  • Memory addresses and device IDs
  • Short hex codes from numbers

Worked example

NumberFormulaResult
255=DEC2HEX(A2)FF
4096=DEC2HEX(A3)1000
16777215=DEC2HEX(A4)FFFFFF

Results calculated in Excel.

Mistakes people make

MistakeWhat to do instead
Building colour codes in the wrong orderHTML is RRGGBB: DEC2HEX(R,2)&DEC2HEX(G,2)&DEC2HEX(B,2)
Lower-case expectedWrap with LOWER

HEX2DEC Β· DEC2BIN

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

  • πŸ“—
    Practice workbook: Engineering & conversion15 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 34 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong