在EXCEL的单元格A1中把第n个“,”和第n-1个“,”之间的字符串提取出来的公式是什么?

2024-11-25 23:51:55
推荐回答(2个)
回答1:

FIND(",",A1,n)的方法找是不行的,因为这里的n是指从第n个字符开始找,而不是从第n个逗号开始找,意思不一样,当然无法查找了。
用下面公式可以实现
=MID(A1,FIND("@",SUBSTITUTE(A1,",","@",n))+1,FIND("@",SUBSTITUTE(A1,",","@",n))-FIND("@",SUBSTITUTE(A1,",","@",n-1))-1)
若用你的公式改造就是这样的
=RIGHT(LEFT(A1,FIND("@",SUBSTITUTE(A1,",","@",n))-1),FIND("@",SUBSTITUTE(A1,",","@",n))-FIND("@",SUBSTITUTE(A1,",","@",n-1))-1)

回答2:

FIND中的第3个参数不是这个意思,它是指从A1中的字符串的第N位开始找。
SUBSTITUTE函数有此功能,所以可以借助它将第N个","替换为"\"后查找出位置。

=MID(A1,FIND("\",SUBSTITUTE(A1,",","\",n))-1,FIND("\",SUBSTITUTE(A1,",","\",n))-FIND("\",SUBSTITUTE(A1,",","\",n-1))-1)

PS:用以置换的字符"\"(或字符串)可以随意设置,但是必须是在A1中不存在的,否则可能得到一个错误的结果。