excel function: inet_aton
inet_aton() converts the Internet host address cp from the standard numbers-and-dots notation into binary data and stores it in the structure that inp points to. inet_aton returns nonzero if the address is valid, zero if not.
Let say for ip A.B.C.D, the formula is :
ip = ((A*256+B)*256+C)*256
For example, if you have an ip of 74.125.45.100 (google.com), the formula would give a result of :
ip = ((74*256+125)*256+45)*256 = 1249717504
usage: =inet_aton(refcell)
Public Function inet_aton(AnyIP As String, Optional IP_Part As Variant) As Double
ipadress = AnyIP
If InStr(1, ipadress, ".") > 0 Then
Dot1 = InStr(1, ipadress, ".")
ipaddress_A_len = Dot1 - 1
ipaddress_A = Mid(ipadress, 1, ipaddress_A_len)
If InStr(Dot1 + 1, ipadress, ".") > 0 Then
Dot2 = InStr(Dot1 + 1, ipadress, ".")
ipaddress_B_len = Dot2 - Dot1 - 1
ipaddress_B = Mid(ipadress, Dot1 + 1, ipaddress_B_len)
If InStr(Dot2 + 1, ipadress, ".") > 0 Then
Dot3 = InStr(Dot2 + 1, ipadress, ".")
ipaddress_C_len = Dot3 - Dot2 - 1
ipaddress_C = Mid(ipadress, Dot2 + 1, ipaddress_C_len)
ipaddress_D = Mid(ipadress, Dot3 + 1, Len(AnyIP) - (Dot3))
Else
ipaddress_C = Mid(ipadress, Dot2 + 1, Len(AnyIP) - (Dot2))
End If 'dot2
Else
ipaddress_B = Mid(ipadress, Dot1 + 1, Len(AnyIP) - (Dot1))
End If 'dot1
'ip = ((A*256+B)*256+C)*256
finaldegisken = ((ipaddress_A * 256 + ipaddress_B) * 256 + ipaddress_C) * 256
Else
finaldegisken = AnyIP
End If 'final
If IsMissing(IP_Part) Then
inet_aton = finaldegisken
Exit Function
End If
If IP_Part = 1 Then inet_aton = ipaddress_A
If IP_Part = 2 Then inet_aton = ipaddress_B
If IP_Part = 3 Then inet_aton = ipaddress_C
If IP_Part = 4 Then inet_aton = ipaddress_D
End Function