对于大数据选择(1000 + 单元格),下面的查询不起作用,但对于小数据选择,它可以工作。除非我按转义键,否则 Excel 将停止工作。
Sub TrimReplaceAndUppercase()
For Each cell In Selection
If Not cell.HasFormula Then
cell.Value = UCase(cell.Value)
cell = Trim(cell)
Selection.Replace What:="-", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
Next cell
End Sub
Run Code Online (Sandbox Code Playgroud)