Excel to sort the IP address

Thinking

将IP地址按“.”分隔,提取“.”之间的每个数,然后根据提取出的列从左至右进行主要字段及次要字段排序

Formula Description

返回一个字符串在另一个字符串中出现的起始位置。
FIND(要查找的字符串,被查找字符串,[开始位置,默认1])

从一个文本字符串的第一个字符开始返回指定个数的字符。
LEFT(字符串,[字符个数])

从文本字符串的指定位置开始,返回指定长度的字符串。
MID(字符串,开始位置,字符数)

Apply the formula

第一个“.”的位置
=FIND(".",A2)
第二个“.”的位置
=FIND(".",A2,4)
第三个“.”的位置
=FIND(".",A2,7)

第一个“.”之前
=LEFT(A2,B2-1)
介于第一个“.”和第二个“.”之间
=MID(A2,B2+1,C2-B2-1)
介于第二个“.”和第三个“.”之间
=MID(A2,C2+1,D2-C2-1)
第三个“.”之后
=MID(A2,D2+1,3)

note

Note that under the WPS after using formulas, sorting fails, you need to copy the entire sheet page Post to Notepad or another text editor, Notepad and then paste the contents to a new page of the sheet, and then sorted.

Sequence

[Sort] - [Custom Sort] - [primary key] - [key] Minor

Show

Guess you like

Origin www.cnblogs.com/luoxiaolei/p/12056208.html