如何使用“右键”和“查找”功能提取单元格中的数据?

时间:2019-04-01 14:45:26

标签: excel excel-formula

我在像这样的单元格D2中有数据:

西国王街1234号 邮局Box 123 内华达州卡森市12345

我知道是否要提取邮政编码,公式应为:

=RIGHT(D2,FIND(" ",D2,FIND(" ",D2)+1)-4)

现在我要提取单元格中的城市信息,公式是什么?

1 个答案:

答案 0 :(得分:1)

假设邮政编码始终从末尾开始5位数字,则您的城市名称始终从第二个数字的末尾[1](和一个空格)开始,并在[NV]之前的逗号[2]处结束。

然后,您可以使用=find()函数查找[1]&[2],然后使用=mid()提取之间的所有文本。我的意思是:=mid(d2,find([1]),find([2]))

完整公式:

=MID(D2, IF(MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))=MIN(IFERROR(FIND("0",D2),LEN(D2)),IFERROR(FIND("1 ",D2),LEN(D2)),IFERROR(FIND("2 ",D2),LEN(D2)),IFERROR(FIND("3 ",D2),LEN(D2)),IFERROR(FIND("4 ",D2),LEN(D2)),IFERROR(FIND("5 ",D2),LEN(D2)),IFERROR(FIND("6 ",D2),LEN(D2)),IFERROR(FIND("7 ",D2),LEN(D2)),IFERROR(FIND("8 ",D2),LEN(D2)),IFERROR(FIND("9 ",D2),LEN(D2))),MAX(IFERROR(FIND("0 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("1 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("2 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("3 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("4 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("5 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("6 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("7 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("8 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("9 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0)),MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0)))+2, FIND(", NV ",D2)-IF(MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))=MIN(IFERROR(FIND("0",D2),LEN(D2)),IFERROR(FIND("1 ",D2),LEN(D2)),IFERROR(FIND("2 ",D2),LEN(D2)),IFERROR(FIND("3 ",D2),LEN(D2)),IFERROR(FIND("4 ",D2),LEN(D2)),IFERROR(FIND("5 ",D2),LEN(D2)),IFERROR(FIND("6 ",D2),LEN(D2)),IFERROR(FIND("7 ",D2),LEN(D2)),IFERROR(FIND("8 ",D2),LEN(D2)),IFERROR(FIND("9 ",D2),LEN(D2))),MAX(IFERROR(FIND("0 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("1 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("2 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("3 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("4 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("5 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("6 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("7 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("8 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0),IFERROR(FIND("9 ",D2,MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0))+1),0)),MAX(IFERROR(FIND("0 ",D2),0),IFERROR(FIND("1 ",D2),0),IFERROR(FIND("2 ",D2),0),IFERROR(FIND("3 ",D2),0),IFERROR(FIND("4 ",D2),0),IFERROR(FIND("5 ",D2),0),IFERROR(FIND("6 ",D2),0),IFERROR(FIND("7 ",D2),0),IFERROR(FIND("8 ",D2),0),IFERROR(FIND("9 ",D2),0)))-2)

额外:

  

如果我要提取邮政编码

那么您应该只使用=right(D2,5) |您原来的公式似乎是在从左而不是从右寻找第一个和第二个“”(空格)。使用right()公式不会成功

  

内华达州所有城市名称的列表

您可以通过wolframalpha.com以“内华达州城市”作为输入来获取它。