Macro to Convert a Hexadecimal Number to a Decimal Number PSS ID Number: Q43456 Article last modified on 04-29-1993 PSS database name: W_eXceL
2.00 2.01 2.10 3.00
WINDOWS
The information in this article applies to: |
- Microsoft Excel for Windows, versions 2.0, 2.1, 3.0 |
Summary:
In Microsoft Exce, you can use a function macro to convert a hexadecimal number to a decimal number. The syntax is as follows, where hexnum is text consisting of the numbers 0-9 and the letters A-F:
=HEX(“hexnum”)
The macro is as follows:
A1: Hex
A2: =ARGUMENT(“value”,2)
A3: =SET.NAME(“result”,0)
A4: =FOR(“i”,1,LEN(value))
A5: =LEFT(RIGHT(value,i),1)
A6: =IF(AND((A5>=“0”),(A5<=“9”)),VALUE(A5),A5)
A7: =IF(AND((A6>=“A”),(A6<=“F”)),CODE(UPPER(A6))-55,A6) A8: =SET.NAME(“result”,result+A7*(16^(i-1)))
A9: =NEXT()
A10: =RETURN(result)
Microsoft provides macro examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Additional reference words: 2.0 2.00 2.01 2.1 2.10 3.0 3.00
Copyright Microsoft Corporation 1993.