假设文本在单元格 $A$1 中:
- 手机号码(数字)开始于:
=FIND("Mobile phone: +",$A$1)+LEN("Mobile phone: +")
- 假设手机号后面没有空格,其长度为:
=FIND("Phone: +",$A$1)-(FIND("Mobile phone: +",$A$1)+LEN("Mobile phone: +")+1)
- 所以手机的数值是:
=VALUE(MID($A$1,FIND("Mobile phone: +",$A$1)+LEN("Mobile phone: +"),FIND("Phone: +",$A$1)-(FIND("Mobile phone: +",$A$1)+LEN("Mobile phone: +")+1)))
您也可以使用My Excel Toolbox 中的Between 函数。这是该函数的简化版本:
Function Between(Text, BeginAfter, EndBefore)
nFirst = InStr(1, Text, BeginAfter)
If nFirst > 0 Then nFirst = nFirst + Len(BeginAfter)
nLast = InStr(nFirst, Text, EndBefore) - 1
Between = Mid(Text, nFirst, (nLast - nFirst + 1))
End Function
完整版具有更多功能。以您为例:
=TRIM(CLEAN(Between($A$1,"Mobile phone: +","Phone: +")))