excel删除中文字符,保留英文和数字VBA公式,筛选关键词使用excel在单元格中只去掉汉字、保留下英文或数字的方法。
Sub test() Dim objRegExp As Object Dim i As Long, arr arr = Range("a1:b" & Cells(Rows.Count, 1).End(xlUp).Row).Value Set objRegExp = CreateObject("VBScript.regExp") With objRegExp .Global = True .Pattern = "[\u4e00-\u9fa5]{1,}" For i = 1 To UBound(arr) 'If .test(arr(i, 1)) Then arr(i, 1) = .Replace(arr(i, 1), "") 'End If Next End With Set objRegExp = Nothing Range("b1").Resize(UBound(arr)) = arr MsgBox "替换完成" End Sub