我想知道一个函数是否可以在单元格的值中搜索“1-”,如果它能找到它,它会复制出“1-”加上接下来的10个字符。
基本上如果“1”在一个单元格中,我想要的功能是为我加上接下来的10个字符。
非常感谢提前!
经过一番研究:
Function RetDigits(sIN As String) As String
Dim lookFor As String, v As String, ary
Dim i As Long, CH As String
lookFor = "1-"
RetDigits = ""
If InStr(sIN, lookFor) = 0 Then Exit Function
ary = Split(sIN, lookFor)
If Len(ary(1)) < 2 Then Exit Function
For i = 1 To 10
CH = Mid(ary(1), i, 1)
If IsNumeric(CH) Then
RetDigits = RetDigits & CH
End If
Next i
RetDigits = "1-" & RetDigits
End Function