A:我们这里使用VBA代码自定义函数来实现,详细的代码清单如下:
FunctionGetNthPos(str, n, separator) As Long
Dim sp As Variant
Dim i As Long, num As Long
sp = Split(str, separator)
If n > UBound(sp) Then
MsgBox “不存在这个位置!”
Exit Function
End If
For i = 0 To n – 1
num = Len(sp(i)) + num
Next
GetNthPos = num + n
EndFunction
效果如下图所示: