HEX2DEC function

HEX2DEC converts a hexadecimal number to its decimal equivalent, essential for decoding batch codes and legacy inventory tracking systems.

=HEX2DEC(number)

Generate a HEX2DEC formula

Describe what you need. The generator will reach for HEX2DEC where HEX2DEC is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How HEX2DEC reads its arguments
numberrequiredHEX2DEC
ArgumentRequiredDescription
numberRequiredA hexadecimal number as text (0-9, A-F), passed as a string or cell reference; if it contains invalid hex characters or exceeds the function's range, returns an error.

Returns

A decimal integer representing the value of the hexadecimal input.

Availability

Excel: All · Google Sheets: Supported

Worked examples

1. Convert supplier batch codes from hex to decimal

IngredientSupplierUnitQty Code (Hex)Expiry
Tomato SauceVendor ACase1A2026-03-15
Olive OilVendor BBottle2F2027-06-20
BasilVendor CBag0C2026-10-01
MozzarellaVendor DKgFF2026-11-15
PastaVendor EBox202028-01-10
=HEX2DEC("1A")

Result: 26

The hex value 1A equals 26 in decimal (1×16 + 10). When Vendor A ships tomato sauce with batch code '1A', converting it to decimal reveals the actual shipment reference number 26, allowing the restaurant to verify receipt against the supplier's decimal-based manifest.

2. Decode hex-encoded quantities in legacy inventory records

IngredientSupplierUnitQty Code (Hex)Expiry
Tomato SauceVendor ACase1A2026-03-15
Olive OilVendor BBottle2F2027-06-20
BasilVendor CBag0C2026-10-01
MozzarellaVendor DKgFF2026-11-15
PastaVendor EBox202028-01-10
=HEX2DEC("FF")

Result: 255

The hex code FF converts to 255 in decimal. The mozzarella's quantity code FF represents 255 kg in the legacy system; converting it ensures the restaurant calculates actual inventory correctly when reconciling stock levels or placing reorders.

3. Sum inventory across multiple hex-encoded shipments

IngredientSupplierUnitQty Code (Hex)Expiry
Tomato SauceVendor ACase1A2026-03-15
Olive OilVendor BBottle2F2027-06-20
BasilVendor CBag0C2026-10-01
MozzarellaVendor DKgFF2026-11-15
PastaVendor EBox202028-01-10
=HEX2DEC("2F")+HEX2DEC("20")+HEX2DEC("0C")

Result: 91

Converting each hex code to decimal: 2F=47, 20=32, 0C=12. Adding them together (47+32+12=91) gives the total units across the three items (olive oil, pasta, and basil). This formula is useful for summing hex-encoded quantities when calculating total inventory after multiple deliveries.

Common errors

Which HEX2DEC error are you seeing?
HEX2DEC returned an error#VALUE!
Check the batch code for typos or verify it's stored correctly. If the value in a cell looks wrong, manually inspect the source data or use SUBSTITUTE to clean unwanted characters before conversion.
#NUM!
For inventory systems, keep batch codes short (e.g., no more than 8 hex digits). If you must handle very large codes, split them into smaller chunks or use a text-based lookup instead of conversion.
#VALUE!
Ensure all inventory records have a quantity or batch code. Use =IFERROR(HEX2DEC(A1), 0) to default to zero, or =IF(A1="", "Missing", HEX2DEC(A1)) to flag incomplete entries.
ErrorWhy it happensHow to fix it
#VALUE!The input contains invalid hexadecimal characters. Hexadecimal only uses 0–9 and A–F; any other character (like G, Z, or symbols) causes this error. For example, HEX2DEC("1G") fails because 'G' is not a hex digit.Check the batch code for typos or verify it's stored correctly. If the value in a cell looks wrong, manually inspect the source data or use SUBSTITUTE to clean unwanted characters before conversion.
#NUM!The hexadecimal number is too large to represent as a decimal integer. HEX2DEC typically supports up to FFFFFFFFFFFFFFFF; values beyond this range exceed the function's limit.For inventory systems, keep batch codes short (e.g., no more than 8 hex digits). If you must handle very large codes, split them into smaller chunks or use a text-based lookup instead of conversion.
#VALUE!The input is an empty string or blank cell. HEX2DEC cannot convert a null or missing value, so referencing an empty cell returns this error.Ensure all inventory records have a quantity or batch code. Use =IFERROR(HEX2DEC(A1), 0) to default to zero, or =IF(A1="", "Missing", HEX2DEC(A1)) to flag incomplete entries.

Tips and when to use something else

  • HEX2DEC is case-insensitive: 'FF', 'ff', and 'Ff' all return 255, so you don't need to standardize batch-code capitalization.
  • Leading zeros don't affect the result—'0FF' and 'FF' both convert to 255, helpful when batch codes have fixed widths.
  • For automatic conversion of entire columns, copy the formula down: put =HEX2DEC(A1) in B1, then drag to B100 to convert all rows at once.
  • If you need the opposite (decimal to hex), use DEC2HEX; or combine HEX2DEC with bitwise functions like BITAND and BITOR if the hex code encodes multiple bit flags in your inventory system.

Frequently asked questions

Can HEX2DEC convert numbers that include letters?
Yes—that's the whole point of hexadecimal. HEX2DEC("1A") = 26, and HEX2DEC("FF") = 255. Letters must be A–F (representing 10–15); any letter outside that range causes a #VALUE! error.
What's the maximum hexadecimal value HEX2DEC can convert?
HEX2DEC handles up to FFFFFFFFFFFFFFFF (9.2 quintillion in decimal). For real-world batch codes and inventory IDs, this limit is almost never reached, so it's not a practical concern.
How do I convert a whole column of hex batch codes to decimal at once?
Enter =HEX2DEC(A1) in a new column (e.g., B1), then copy the formula down to all rows. Excel and Google Sheets will automatically adjust the cell reference for each row (A2, A3, etc.).
Should I use HEX2DEC if my inventory codes are actually decimal, not hexadecimal?
No. HEX2DEC is only for true hexadecimal numbers. If your codes are already in decimal, use them as-is. Using HEX2DEC on a decimal number will give wrong results (e.g., HEX2DEC("20") = 32, not 20).

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17