首页 > 其他分享 >Excel 2016 VBA 提取单元格的中文字符

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

时间:2022-12-02 09:44:45浏览次数:47  
标签:VBA End regx chinese strs 单元格 Excel str

启用开发工具
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

标签:VBA,End,regx,chinese,strs,单元格,Excel,str
From: https://www.cnblogs.com/vipsoft/p/16941993.html

相关文章