Excel中查找字符第N次出现的位置
1、在Excel中按下ALT+F11,打开VBA编辑器

2、在VBA编辑界面菜单中选择“插入”-“模块”输入第三步中的代码

3、'查询findStr在fullStr中第count次出现的位置
Function getStrLoc(findStr As String, fullStr As String, count As Integer)
Dim ct As Integer, i As Integer
ct = 0
For i = 1 To count
ct = VBA.inStr(ct + 1, fullStr, findStr, vbTextCompare)
Next
getStrLoc = ct
End Function

4、然后在表格中使用下面的公式就可以了
例:A1="我爱你比你爱我还要多一点"
=getStrLoc("你",A1,2)
则“你”第2次出现的位置为5

阅读量:196
阅读量:65
阅读量:51
阅读量:131
阅读量:128