View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Looking for a formula that will convert IP address for sorting

Sub leadingzeros()
lr = Cells(Rows.Count, "j").End(xlUp).Row
For Each c In Range("j2:j" & lr)
Select Case InStr(c, ".") - 1
Case 1: n = "00"
Case 2: n = "0"
Case 3: n = ""
Case Else
End Select
c.Value = n & c
Next c
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"metelcom" wrote in message
...
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