HEX2DEC Function
Converts a hexadecimal number to decimal.
Category
Engineering
Available in
All versions, Microsoft 365
Returns
A number
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
Arguments
| Argument | Required? | What it does |
|---|---|---|
| number | Yes | The 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.
| A | B | |
|---|---|---|
| 1 | Hex | Decimal |
| 2 | A5 | 165 |
| 3 | FF | 255 |
| 4 | 7D0 | 2000 |
| 5 | FFFFFFFF5B | -165 |
Example 2 — Split a colour code into RGB
Pull out each pair of characters and convert it.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Colour | Red | Green | Blue |
| 2 | 2CD1A4 | 44 | 209 | 164 |
| 3 | ff8800 | 255 | 136 | 0 |
- Green: =HEX2DEC(MID(A2,3,2))
- Blue: =HEX2DEC(RIGHT(A2,2))
- 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.

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.