How to convert numbers between decimal and hexadecimal

To convert numbers between decimal and hexadecimal you use the equivalent Excel built-in function.

To convert from decimal to hexadecimal use the function DEC2HEX.

Syntax

DEC2HEX(number;places)

Number: The decimal number you want to convert into hexadecimal.

Places: Optional, the number of characters or positions to use. You can use this option to pad the return value with leading zeros. If number is negative, then the places parameter is ignored.

Examples:

1. A1 = 35; B1 = DEC2HEX(A1;4).

The returned vale in B1 will be 0023. Notice the leading zeros.

2. A1 = 1234; B1 = DEC2HEX(A1).

The returned vale in B1 will be 4D2.

To convert from hexadecimal to decimal use the function HEX2DEC.

Syntax

HEX2DEC (number)

Number: The hexadecimal number you want to convert into decimal. It cannot contain more than 10 characters.

 

Examples:

1. A1 = 100; B1 = HEX2DEC(A1).

The returned value in B1 will be 256.

2. A1 = FF25; B1 = HEX2DEC(A1).

The returned value in B1 will be 65317.

3. A1 = FFFFFFF6CC; B1 = HEX2DEC(A1).

The returned value in B1 will be -2356 (negative number).