|
楼主 |
发表于 2019-9-16 11:35
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
谢谢老师!
http://club.excelhome.net/thread-18045-3-1.html
Function FindStrPro(strObj As String, strSou As String, strLen As Integer) As String
Dim s(3) As String
Dim l(3) As Integer
s(3) = "*" & strObj & "*"
If strSou Like s(3) Then
Do
s(0) = strSou
l(0) = Len(s(0))
l(1) = Int(l(0) * 0.5 + 0.5)
l(2) = l(0) - l(1)
If l(2) > strLen Then
s(1) = Left(s(0), l(1))
s(2) = Right(s(0), l(2))
If s(1) Like s(3) Then
strSou = s(1)
ElseIf s(2) Like s(3) Then
strSou = s(2)
Else: strSou = Mid(s(0), l(1) - strLen + 1, strLen * 2 - 2)
Exit Do
End If
Else
Exit Do
End If
Loop
FindStrPro = FindStr(strObj, strSou, strLen)
Else: FindStrPro = ""
End If
End Function
Private Function FindStrPos(strObj As String, ByVal strSou As String, strLen As Integer) As Integer
Dim s1 As String
Dim s2 As String
s1 = strSou
s2 = FindStrPro(strObj, strSou, strLen)
If s2 <> "" Then
FindStrPos = InStr(s1, s2)
Else
FindStrPos = 0
End If
End Function |
评分
-
2
查看全部评分
-
|