Convert IP Address to a hexadecimal

  • Thread starter Thread starter eluehmann
  • Start date Start date
E

eluehmann

I know this is a long shot but is there anyone out there that knows ho
to convert IP of the system to hexadecimal number
 
I know this is a long shot but is there anyone out there that knows how
to convert IP of the system to hexadecimal number?

One way is to start with the four components in A1, B1, C1, and D1. (If
they're in one cell, they can be split using "Data >> Text to columns.)

Then, in E1, put
=DEC2HEX(A1,2)&DEC2HEX(B1,2)&DEC2HEX(C1,2)&DEC2HEX(D1,2)

(I'd also add some checks that the IP is valid.)
 
I know this is a long shot but is there anyone out there that knows how
to convert IP of the system to hexadecimal number?

Here is a UDF (user defined function) that should work.

To enter this, <alt><F11> opens the VB Editor.
Ensure your project is highlighted in the Project Explorer window, then
Insert/Module.

Paste the code below into the window that opens.

To use this, you can enter a formula of the form

=IP2HEX(A1) where A1 contains your IP address in standard format (i.e.
something between 0.0.0.0 and 255.255.255.255)

=====================================
Function IP2Hex(IPadr As String) As String
Dim IP
Dim j As Integer

IP = Split(IPadr, ".")

For j = 0 To 3
IP2Hex = IP2Hex & Right("0" & Hex(IP(j)), 2)
Next j

End Function
========================================


--ron
 
Back
Top