Category: FUNCTION | Updated: 2026-11-22

How to Use the HEX2DEC Function in Google Sheets | Convert Hexadecimal to Decimal

Syntax

=HEX2DEC(signed_hexadecimal_number)
  • signed_hexadecimal_number: Specifies the hexadecimal value (a string or number up to 10 characters consisting of 0–9 and A–F) to convert to decimal.

Practical Example with a Table

Here is an example of converting various hexadecimal values (such as RGB color values and negative hex numbers) to decimal using the HEX2DEC function.

Input (Hexadecimal) Formula Result (Decimal) Description
FF =HEX2DEC(A2) 255 16 × 15 + 15 = 255
1A =HEX2DEC(A3) 26 16 × 1 + 10 = 26
100 =HEX2DEC(A4) 256 16 squared
FFFFFFFFFF =HEX2DEC(A5) -1 Negative number in 40-bit two’s complement

Common Errors and Notes

  • #NUM! Error: Occurs if the input contains invalid hexadecimal characters (letters G or higher, #, or prefixes like 0x), or if more than 10 characters are specified.
  • #VALUE! Error: May occur if an invalid argument is passed regarding number/string handling. When writing a hexadecimal value containing letters directly inside a formula, always enclose it in double quotes like "1A".
  • 40-Bit Signed Convention: For 10-character values, if the most significant digit is 8 through F, it is interpreted as a negative integer.

Frequently Asked Questions

Q. Can I enter lowercase letters (a–f) in the HEX2DEC function?

A. Yes. Uppercase (A–F) and lowercase (a–f) are not distinguished; both convert to the exact same decimal number.

Q. How do I convert a web color code like "#FF00AA" to decimal?

A. Because a leading "#" symbol causes an error, strip "#" first using `=HEX2DEC(SUBSTITUTE(A1, "#", ""))`, or extract and convert 2 characters at a time for R, G, and B.