HEX2DEC Function

Converts a hexadecimal number to decimal.

Category

Engineering

Available in

All versions, Microsoft 365

Returns

A number

Want to practice HEX2DEC in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

HEX2DEC converts a hexadecimal number into decimal. Hexadecimal (base 16) uses 0–9 and then A–F for 10–15. Decimal (base 10) is the everyday number system.

Negative numbers use a fixed 10-character form called two's complement: the first digit acts as the minus sign. For example −1 is 1111111111 in binary, 7777777777 in octal and FFFFFFFFFF in hex. So HEX2DEC reads a 10-character hexadecimal value starting with 8–F as negative.

Syntax

=HEX2DEC(number) Explain

Arguments

ArgumentRequired?What it does
numberYesThe hexadecimal number to convert, as text or a number — up to 10 characters. Upper- or lower-case letters both work.

Examples

Example 1 — Hexadecimal to decimal

Each row converts the value in column A.

B2fx=HEX2DEC(A2)
AB
1HexDecimal
2A5165
3FF255
47D02000
5FFFFFFFF5B-165
=HEX2DEC(A2) Explain

Example 2 — Split a colour code into RGB

Pull out each pair of characters and convert it.

B2fx=HEX2DEC(LEFT(A2,2))
ABCD
1ColourRedGreenBlue
22CD1A444209164
3ff88002551360
=HEX2DEC(LEFT(A2,2)) Explain
  1. Green: =HEX2DEC(MID(A2,3,2))
  2. Blue: =HEX2DEC(RIGHT(A2,2))
  3. Lower-case codes such as ff8800 work too.

Common mistakes

  • #NUM! The text isn't valid hexadecimal (for example a 2 in binary), it's longer than 10 characters.

Notes

  • The answer is a real number you can calculate with.
  • Related functions: DEC2HEX, HEX2BIN, HEX2OCT, DECIMAL.
Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.