我找到了一个宏,它可以从 Excel 中删除表情符号。我遇到的难题是,我不知道如何让它循环。它只适用于范围内的第一个单元格。理想情况下,我希望它能够遍历整个活动工作表或通过选定的文本组运行。这两种方法都可以。
任何帮助都将不胜感激。谢谢。
Sub kleanIt()
Dim r As Range, v As Variant, L As Long
Dim CH As String, i As Long, N As Long
Set r = ActiveCell
v = r.Value
L = Len(v)
For i = L To 1 Step -1
CH = Mid(v, i, 1)
N = AscW(CH)
If N < 1 Or N > 256 Then
v = Replace(v, CH, "")
End If
Next i
r.Value = v
End Sub
答案1
尝试一下:
Sub kleanIt()
Dim r As Range, v As Variant, L As Long
Dim CH As String, i As Long, N As Long
For Each r In ActiveSheet.UsedRange
v = CStr(r.Value)
If v <> "" Then
L = Len(v)
For i = L To 1 Step -1
CH = Mid(v, i, 1)
N = AscW(CH)
If N < 1 Or N > 256 Then
v = Replace(v, CH, "")
End If
Next i
r.Value = v
End If
Next r
End Sub