I am working on a fairly simple worksheet where if a cell contains a hexadecimal value I want to convert it to decimal, otherwise if it is already in decimal format we just leave it. Something like:
=IF(A1 is hex, HEX2DEC(A1),A1)
Any ideas/suggestions would be awesome. Thanks in advance.
I have searched around a bit but can not seem to find anything.
CodePudding user response:
This formula will convert the number from hexadecimal to decimal, if it is possible to convert from hexadecimal to decimal:
=IFERROR(HEX2DEC(A1), A1)
To my knowledge, there isn't a way to distinguish a hexadecimal number from a decimal number, if the hexadecimal number only has digits [0-9] unless of course you have a narrower definition of what your input is.
CodePudding user response:
Looks like being able to identify a particular string as text is not possible but I came up with a workaround. And the answer on how to convert longer strings worked!
Thanks everyone for the prompt input.