会用excel表格中的VAB的高手进
答案:2 悬赏:60 手机版
解决时间 2021-03-20 11:33
- 提问者网友:眉目添风霜
- 2021-03-20 03:37
excel表格中,每一个单元格里面都有中文和英文,用VBA写一个一键删除所有单元格内中文的程序,单元格内中文字体为宋体,英文为另外一种字体arial narrow,字体都为12号
最佳答案
- 五星知识达人网友:一叶十三刺
- 2021-03-20 04:19
Sub test()
Dim rg As Range, Rxp
Set Rxp = CreateObject("VBScript.RegExp")
For Each rg In ActiveSheet.UsedRange
With Rxp
.Global = True
.Pattern = "\W"
rg.Value = .Replace(rg, "")
End With
Next rg
End Sub
Dim rg As Range, Rxp
Set Rxp = CreateObject("VBScript.RegExp")
For Each rg In ActiveSheet.UsedRange
With Rxp
.Global = True
.Pattern = "\W"
rg.Value = .Replace(rg, "")
End With
Next rg
End Sub
全部回答
- 1楼网友:第幾種人
- 2021-03-20 05:44
Dim i As Integer
Dim C As String
Sub CC()
Dim rC As Range
Sheets(1).Select
For Each rC In Sheets(1).UsedRange
i = 1
C = rC
Call doClear(i, C)
rC = Trim(C)
Next
End Sub
Private Sub doClear(s, Cs)
If i > Len(Cs) Then Exit Sub
If Abs(Asc(Mid(Cs, s, 1))) > 128 Then
C = Replace(Cs, Mid(Cs, s, 1), "", , , vbBinaryCompare)
Else
i = i + 1
End If
Call doClear(i, Cs)
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯