自由提取数字、汉字、字母的Excel宏命令
myget(A1,1)
第一个参数为单元格,第二个参数(空:数字,1:中文,2:英文)
代码放到模块里
Function MyGet(Srg As String, Optional n As Integer = False)
Dim i As Integer
Dim s, MyString As String
Dim Bol As Boolean
For i = 1 To Len(Srg)
s = Mid(Srg, i, 1)
If n = 1 Then
Bol = Asc(s) < 0
ElseIf n = 2 Then
Bol = s Like "[a-z,A-Z]"
ElseIf n = 0 Then
Bol = s Like "#"
End If
If Bol Then MyString = MyString & s
Next
MyGet = IIf(n = 1 Or n = 2, MyString, Val(MyString))
End Function
原创文章,作者:熊阿初,如若转载,请注明出处:https://www.guofc.com/338.html