Function GetMyString(MyValue As Range) '提取英文及數(shù)字、排除中文字
Application.Volatile
For i = 1 To Len(MyValue)
If Asc(Mid(MyValue, i, 1)) > 0 Then
MyString = MyString & Mid(MyValue, i, 1)
End If
Next
GetMyString = MyString
End Function
Function getchn(MyValue As Range)'提取中文
Dim i As Integer
Dim chn As String
For i = 1 To Len(MyValue)
If Asc(Mid(MyValue, i, 1)) < 0 Then
chn = chn & Mid(MyValue, i, 1)
End If
Next
getchn = chn
End Function
******************************************
Function 漢字(reg, Optional gb As Boolean = True) As String
With CreateObject("VBSCRIPT.REGEXP")
.Global = True
If gb Then
.Pattern = "[^\u4e00-\u9fa5,;,]"
Else
.Pattern = "[\u4e00-\u9fa5,;,]"
End If
漢字 = .Replace(reg, "")
End With
End Function
代碼
Function 英文(reg, Optional gb As Boolean = True) As String
With CreateObject("VBSCRIPT.REGEXP")
.Global = True
If gb Then
.Pattern = "[!^\u4e00-\u9fa5,;,]"
Else
.Pattern = "[!\u4e00-\u9fa5,;,]"
End If
英文 = .Replace(reg, "")
End With
End Function
聯(lián)系客服