我目前正在解析地址。我唯一的要求是每个地址单元格中不应超过40个字符(地址1,地址2,地址3等)。问题是地址都有不同的格式,我想防止在中间切换单词。地址示例(在G列中): Naaaaaaaaaaaaaaaaaaaaaaaame,342 Streeeeeet,city,452342邮编,国家 这到底有多远:
Adress3=IF(LEN(G3)>40;RIGHT(G3;LEN(G3)-FIND("*";SUBSTITUTE(G3;" ";"*";LEN(G3)-LEN(SUBSTITUTE(G3;" ";"")))));"")
Adress1==IF(I3<>""; IF(RIGHT(IF(I3<>"";TRIM(SUBSTITUTE(G3; I3; "")); G3);1)=",";LEFT(IF(I3<>"";TRIM(SUBSTITUTE(G3; I3; "")); G3);LEN(IF(I3<>"";TRIM(SUBSTITUTE(G3; I3; "")); G3))-1);IF(I3<>"";TRIM(SUBSTITUTE(G3; I3; "")); G3)); IF(I3<>"";TRIM(SUBSTITUTE(G3; I3; "")); G3))
这有效,但是我需要找到一种方法来多次执行此操作(因为有些地址非常长)所以我得到类似的东西:
地址1:40个字符
地址2:40个字符
地址3:剩余字符
有没有办法在不使用VBA的情况下解决这个问题? 我希望我有意义,并希望得到任何建议!!
答案 0 :(得分:0)
这三个渐进的公式似乎适用于你的单个例子。
G5:K5中的公式为:
=TRIM(LEFT(SUBSTITUTE(G3, " ", REPT(" ", 99), 40-LEN(SUBSTITUTE(LEFT(G3, 40), " ", ""))), 40))
=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(G3, LEN(G5&REPT(" ", 1)), 40), " ", REPT(" ", 99), 40-LEN(SUBSTITUTE(LEFT(MID(G3, LEN(G5&REPT(" ", 1)), 40), 40), " ", ""))), 40)), "")
=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(G3, LEN(G5&H5&REPT(" ", 2)), 40), " ", REPT(" ", 99), 40-LEN(SUBSTITUTE(LEFT(MID(G3, LEN(G5&H5&REPT(" ", 2)), 40), 40), " ", ""))), 40)), "")
=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(G3, LEN(G5&H5&I5&REPT(" ", 3)), 40), " ", REPT(" ", 99), 40-LEN(SUBSTITUTE(LEFT(MID(G3, LEN(G5&H5&I5&REPT(" ", 3)), 40), 40), " ", ""))), 40)), "")
=IFERROR(TRIM(LEFT(SUBSTITUTE(MID(G3, LEN(G5&H5&I5&J5&REPT(" ", 4)), 40), " ", REPT(" ", 99), 40-LEN(SUBSTITUTE(LEFT(MID(G3, LEN(G5&H5&I5&J5&REPT(" ", 4)), 40), 40), " ", ""))), 40)), "")
请注意,H5中的公式取决于G5中的结果,而I5中的公式取决于H5和G5中的结果。
不确定您对H5中的尾随逗号可能要做什么。