Sorting Excel column by IP address
As nixda mentioned in the comments, helper columns will make this possible. You have two options for maintaining the sheet afterward:
- Add all new IPs in the split helper columns.
- Repeat the Text-to-columns procedure for new additions.
Here's the procedure:
Select your IP column and click
Data
>Text-to-Columns
Choose the Delimted option and click Next. Check the
Other
checkbox and enter a period.
. Click Next.Keep all of the columns, keep them as General, click the range icon to edit the
Destination
section.Select the columns where you want the new text to appear. Hit the Enter key.
Make sure your range is selected and click
Data
>Sort
. Enter the sorting criteria. Keep adding levels for each octet.Here's the end result:
I realize this is an old post, but in the interest of providing a working solution, I present the following.
Just put this formula in an adjacent cell and update the references to point to the cell containing your IP address (A1 in this example). This will produce a result similar to 010.121.008.030, which can then be sorted (correctly) alphabetically. Then set the new column's width to zero and voila. Time to enjoy a cup of coffee.
=TEXT(MID(A1,1,FIND(".",A1)),"000")&"."&TEXT(MID(A1,FIND(".",A1)+1,FIND(".",A1,FIND(".",A1)+1)-1-FIND(".",A1)),"000")&"."&TEXT(MID(A1,FIND(".",A1,FIND(".",A1)+1)+1,FIND(".",A1,FIND(".",A1,FIND(".",A1)+1)+1)-1-FIND(".",A1,FIND(".",A1)+1)),"000")&"."&TEXT(MID(A1,FIND(".",A1,FIND(".",A1,FIND(".",A1)+1)+1)+1,LEN(A1)),"000")
In addition to John Homer's answer, I here provide a formula that also works in Apple's Numbers application, as TEXT
function does not exist there. Also tested in Google Docs.
=DEC2HEX(LEFT(B2,FIND(".",B2)-1),2)
&
DEC2HEX(MID(
B2,
FIND(".",B2)+1,
FIND(
".",
B2,
FIND(".",B2)+1
) - FIND(".",B2) - 1
),2)
&
DEC2HEX(MID(
B2,
FIND(
".",
B2,
FIND(".",B2)+1
) + 1,
FIND(
".",
B2,
FIND(
".",
B2,
FIND(".",B2)+1
)+1
) - FIND(
".",
B2,
FIND(".",B2)+1
) - 1
),2)
&
DEC2HEX(RIGHT(
B2,
LEN(B2) - FIND(
".",
B2,
FIND(
".",
B2,
FIND(".",B2)+1
)+1
)
),2)