需要建立宏,把下面的内容完全复制粘贴,覆盖原有的宏就可以,然后点运行。有需要的同事可以保存下来。
一、去掉字母、数字,符号等,在另一行提取出汉字
Sub 查和替换()
Dim regEx As Object
Dim i As Double
Set regEx = CreateObject("VBSCRIPT.REGEXP")
regEx.Pattern = "[^\u4e00-\u9fa5]"
regEx.IgnoreCase = True
regEx.Global = True
For i = 1 To ActiveSheet.UsedRange.Rows.Count
Cells(i, 2).Value = regEx.Replace(Cells(i, 1), "")
Next i
Set regEx = Nothing
End Sub
二、去掉汉字,字母,符号等,在另一行提取出数字
Sub 查和替换()
Dim regEx As Object
Dim i As Integer
Set regEx = CreateObject("VBSCRIPT.REGEXP")
正则表达式提取中文
regEx.Pattern = "\D+"
regEx.IgnoreCase = True
regEx.Global = True
For i = 1 To ActiveSheet.UsedRange.Rows.Count
Cells(i, 2).Value = regEx.Replace(Cells(i, 1), "")
Next i
Set regEx = Nothing
End Sub
三、去掉汉字,数字,符号等,在另一行提取出字母
Sub 查和替换()
Dim regEx As Object
Dim i As Double
Set regEx = CreateObject("VBSCRIPT.REGEXP")
regEx.Pattern = "[^a-zA-Z]"
regEx.IgnoreCase = True
regEx.Global = True
For i = 1 To ActiveSheet.UsedRange.Rows.Count
Cells(i, 2).Value = regEx.Replace(Cells(i, 1), "")
Next i
Set regEx = Nothing
End Sub

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。