Convert large 18 digit integer numbers to Hexadecimal number

manikandan23

New Member
Joined
Sep 6, 2017
Messages
3
Hi, I am looking to convert large 18 digit (Product Serial Numbers - Electronic Serial Numbers) numbers to its equivalent Hexadecimal numbers.

Since my number is huge, I am getting #NUM ! error when I use DEC2HEX function.

Can anyone please suggest me how do I do that in Excel?

My data looks like below: (Only some sample ESNs I posted here. But my excel is a huge list of ESNs to be converted to its equivalent Hex value)
256691622700551235
256691622700554551
256691622700554513
256691622700553880
256691622700553570
256691622700553001
256691622700169272
256691622700554824
256691622700555366
256691622700553315
256691622700554353
256691622700627288
256691622700550435
256691622700554581
256691622700554614
256691622700615734
256691622700410773
256691622700590150
256691622700590217
256691622700590725
256691622700590695

<colgroup><col></colgroup><tbody>
</tbody>

Thanks in Advance!
Mani A
 
I was wondering how the code could be changed to give the hexdec in reverse order.
For example the hex return for 1,000 = 3E8 but the reverse needed to poke would be E8 03
Give this function a try...
Code:
Function DecToHexRev(ByVal V As Variant, Optional WithSpaces As Boolean = True) As String
  Do Until V = 0
    DecToHexRev = DecToHexRev & Mid("0123456789ABCDEF", CDec(V) - 16 * Int(CDec(V) / 16) + 1, 1)
    V = Int(CDec(V) / 16)
  Loop
  If Len(DecToHexRev) Mod 2 Then DecToHexRev = "0" & DecToHexRev
  If WithSpaces Then DecToHexRev = Trim(Format(DecToHexRev, Application.Rept("@@ ", Len(DecToHexRev))))
End Function
Note: I added an optional argument which controls whether spaces will be used to separate the output into space delimited hex-pairs or not. I defaulted it to True because your example showed you wanted the spaces. To suppress the spaces, simply pass False in for the optional argument.
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Give this function a try...
Code:
Function DecToHexRev(ByVal V As Variant, Optional WithSpaces As Boolean = True) As String
  Do Until V = 0
    DecToHexRev = DecToHexRev & Mid("0123456789ABCDEF", CDec(V) - 16 * Int(CDec(V) / 16) + 1, 1)
    V = Int(CDec(V) / 16)
  Loop
  If Len(DecToHexRev) Mod 2 Then DecToHexRev = "0" & DecToHexRev
  If WithSpaces Then DecToHexRev = Trim(Format(DecToHexRev, Application.Rept("@@ ", Len(DecToHexRev))))
End Function
Note: I added an optional argument which controls whether spaces will be used to separate the output into space delimited hex-pairs or not. I defaulted it to True because your example showed you wanted the spaces. To suppress the spaces, simply pass False in for the optional argument.


Though this code does reverse the output it only mirrors it instead of giving reverse byte output.
What I am needing it to do is return the (3E8) hexdec value as E8 03, your code gives the return as 08 E3.
 
Upvote 0
Taking a decimal value of 1000 = 03 E8 in Hex
what I need is for it to read the byte in reverse, starting with the first byte as E8 and the second as 03 and output it as E8 03
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top