Const sList = "[]{}【】()()", sRange = "B5:P10"Sub Arrange() Dim aRr Dim i As Integer, j As String Dim rT, rC As Range Set rT = Sheets(1).Range(sRange) ReDim aRr(1 To Len(sList)) For i = 1 To UBound(aRr) aRr(i) = Mid(sList, i, 1) Next For Each rC In rT j = rC For i = 1 To UBound(aRr) j = Replace(j, aRr(i), "") Next rC = j NextEnd Sub
你最好吧特殊字元放在一個字串裡,我可以試試為你寫一個
Const sList = "[]{}【】()()", sRange = "B5:P10"Sub Arrange() Dim aRr Dim i As Integer, j As String Dim rT, rC As Range Set rT = Sheets(1).Range(sRange) ReDim aRr(1 To Len(sList)) For i = 1 To UBound(aRr) aRr(i) = Mid(sList, i, 1) Next For Each rC In rT j = rC For i = 1 To UBound(aRr) j = Replace(j, aRr(i), "") Next rC = j NextEnd Sub
你可以自己修改第一句中的區域和需要剔除的特殊字元