I want a formula that will create an IP address that can be sorted properly
example:
Row A Row B
11.23.45.678 011.023.045.678
First, "678" is not a valid octet of an IP address. Anyway....
Copy-and-Paste Special Value the range of cells in column A into
column B, then use the following macro (making sure the range in B is
still selected):
Sub convertIP()
For Each c In Selection
ip = Split(c.Value, ".", 4)
For i = 0 To 3
Select Case Len(ip(i))
Case 1: ip(i) = "00" & ip(i)
Case 2: ip(i) = "0" & ip(i)
Case Else
End Select
Next i
c.Value = Join(ip, ".")
Next c
End Sub
If you are not familiar with using macros, to enter the macro, press
alt+F11, click on Insert>Module, then cut-and-paste the the macro text
above into the editing window. Return to the Excel worksheet. After
doing the cut-and-paste into column B, press alt+F8, select convertIP,
and click Run.
Caveat emptor: The above macro code is not bullet-proof. It gets
errors if the original IP address does not have at least 3 dots, for
example.