thsftp Posts: 1, Reputation: 1 New Member #1 Jan 23, 2014, 01:21 AM
Convert Hexadecimal number Larger than 10 digits
Hi,

I'm new to Excel VBA, can anyone help me with converting large Hexadecimal Number in Excel 2007.

I've used the following code from this forum, it converts but not absolutely accurately:

code:

Public Function HexToDec(Hex As String) As Double

Dim I As Long
Dim j As Variant
Dim k As Long
Dim n As Long
Dim HexArray() As Double

n = Len(Hex)
k = -1
ReDim HexArray(1 To n)
For I = n To 1 Step -1
j = Mid(Hex, I, 1)
k = k + 1
Select Case j
Case 0 To 9
HexArray(I) = j * 16 ^ (k)
Case Is = "A"
HexArray(I) = 10 * 16 ^ (k)
Case Is = "B"
HexArray(I) = 11 * 16 ^ (k)
Case Is = "C"
HexArray(I) = 12 * 16 ^ (k)
Case Is = "D"
HexArray(I) = 13 * 16 ^ (k)
Case Is = "E"
HexArray(I) = 14 * 16 ^ (k)
Case Is = "F"
HexArray(I) = 15 * 16 ^ (k)
End Select
Next I
HexToDec = Application.WorksheetFunction.Sum(HexArray)

End Function

The above code gives the output as "1394546016882220" in Excel to the input Hexa Value "04F4550BF58E28", whereas the correct answer is "1394546016882216".

 JBeaucaire Posts: 5,426, Reputation: 997 Software Expert #2 Jan 23, 2014, 05:03 PM
Not sure you're going to get any better than that. Excel's precision is a known issue.

Numeric precision in Microsoft Excel - Wikipedia, the free encyclopedia

 Question Tools Search this Question Search this Question: Advanced Search

## Check out some similar questions!

A license plate has a three-digit number printer on it. The product of the digits is 210, their sum is 18, and the numbers appears in descending order from left to right. What is the license plate number?

I would like to convert a list of decimal formatted numbers to a 14 digit hexadecimal, any ideas? Sample data: 256691418206312704 256691418207356561 256691418209601124 256691418306358384 Thanks

Select a natural number between 1 to 50. Square the digits and add. Repeat this process until you see a pattern. What other numbers end with one? What happen if you do the process to number 37? What conclusion can you give?

Excel digits convert into text? [ 1 Answers ]

I just want to know that if I enter some value like "1000" it can b change into text form like "one thousand" if there is any formula *** tell me this is my mailing address >Removed<

How many 4 digits number formed of only odd digits are divisible by five