地址拆分公式

时间:2013-01-01 22:57:03

标签: excel worksheet-function

关于如何在Excel中分隔地址的任何想法。目前,我有大约300个流动格式的地址:

1234 Address City,AL 55555

我已经在网上看了,我发现了如何分开城市和邮政编码。现在我遇到一个问题,在一个单独的单元格中获取城市和地址。关于我如何做到这一点的任何想法?

1 个答案:

答案 0 :(得分:2)

如果它总是采用那种确切的格式,那么如果城市只有一个单词(地址中有无限的空格):

Addr:  =LEFT(A5,
        FIND("~",SUBSTITUTE(A5," ","~",FIND(",",A5)-1-LEN(SUBSTITUTE(LEFT(A5,FIND(",",A5)-1)," ","")))))
City:  =MID(A5,
        FIND("~",SUBSTITUTE(A5," ","~",FIND(",",A5)-1-LEN(SUBSTITUTE(LEFT(A5, FIND(",",A5)-1)," ",""))))+1,
        FIND(",",A5) - 1 - FIND("~",SUBSTITUTE(A5," ","~",FIND(",",A5)-1-LEN(SUBSTITUTE(LEFT(A5, FIND(",",A5)-1)," ","")))))
State: =MID(A1,FIND(",",A1)+2,2)
Zip:   =RIGHT(A1,5)