0

This question is based of the module from here: How can I convert a hex number to a decimal number in Excel?

The Module I am using (from above link) is as such:

Option Explicit

Public Function HexadecimalToDecimal(HexValue As String) As Double

' If hex starts with 0x, replace it with &H to represent Hex that VBA will understand
Dim ModifiedHexValue As String
ModifiedHexValue = Replace(HexValue, "0x", "&H")

HexadecimalToDecimal = CDec(ModifiedHexValue)

End Function

I have it doing:

HexadecimalToDecimal(00007FF7BE6B0000)

Which gives the correct result of

"140702028333056"

I would like help on reversing the above module to go from in reverse, so Decimal back to Hexadecimal.

DecimaltoHexdecimal(140702028333056)

Should result in:

"00007FF7BE6B0000" (or obviously "7FF7BE6B0000")

Any help or guidance would sure be appreciated!

1 Answers1

1

Use Hex()

Function myDec2Hex(val As Double) As String
    myDec2Hex = Hex(val)
End Function

enter image description here

Scott Craner
  • 23,868