Excel 2016 VBA 提取單元格的中文字符

啓用開發工具
image
方式一:【右鍵Sheet1 】->【查看代碼】
方式二:【開發者工具】->【Visual Basic】
image

image

image

image

Function chinese(rng As String)
Dim regx As Object
Dim strs, str, i
Set regx = CreateObject("vbscript.regexp")
With regx
    .Global = True
    .Pattern = "[\u4e00-\u9fa5]"
    Set strs = .Execute(rng)
    For Each i In strs
        str = str & i
    Next
    If Len(str) > 0 Then
        chinese = str
    Else
        chinese = ""
    End If
End With
End Function

image

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章