# How to format a Microsoft Excel 2007 cell in hexadecimal?

I would like a format a cell in Microsoft Excel 2007 in hexadecimal but am not finding how to do this.

Is there a built-in way to change the base from 10 to 16 for a cell?

-

If you want to format a cell so that you can type in a decimal number and automatically have it displayed as a hexadecimal number, then that's not possible. You can either format the cell as text and enter hexadecimal numbers directly (but note that Excel cannot use those for calculations), or use the `DEC2HEX()` and `HEX2DEC()` functions to convert between base 10 and base 16.

-
For reference, there is also `DEC2BIN()` which converts to binary. For fixed width binary, use something like `=TEXT(DEC2BIN(A1), "0000")` – Tor Klingberg Jul 28 '15 at 14:11

If cell to be converted is `A1` use `=DEC2HEX(A1)`.

-

If you need to perform mathematical operations on numbers converted to hex, first convert them to decimal, perform the operation, then convert back to hex.

For example, if cell A1 has a hex number, such as would be created from this formula:

=DEC2HEX(17)

which would be displayed as 11, and cell A2 has formula:

=DEC2HEX(165)

which would be displayed as A5, and you want to add them together, then this formula would get the desired result:

=DEC2HEX(HEX2DEC(A1)+HEX2DEC(A2))

which would be displayed as B6

-