我已经编写了一个宏,可以完全实现我所需要的功能,但是,它大量使用了.Select函数,一旦运行,它就会在excel中产生大量的延迟-以及在工作表中来回滑动时,看起来有点奇怪。
在保持完全相同的结果的同时,最好的清理方法是什么?
Sub Format()
Columns("F:F").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("H:H").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("F1").Select
ActiveCell.FormulaR1C1 = "Calling Name"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Destination Name"
Range("F2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(INDEX(NAME,MATCH(RC[-1],NUMBER,0)),""Other/External"")"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F10000")
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(INDEX(NAME,MATCH(RC[-1],NUMBER,0)),""Other/External"")"
Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H10000")
Range("J2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-3],3)"
Range("J2").Select
Selection.AutoFill Destination:=Range("J2:J10000")
Range("J2:J10000").Select
Range("J1").Select
ActiveCell.FormulaR1C1 = "Filter"
Columns("J:J").Select
Selection.AutoFilter
ActiveSheet.Range("$J$1:$J$10000").AutoFilter Field:=1, Criteria1:="=497", _
Operator:=xlOr, Criteria2:="=971"
Range("A1").Select
Columns("A:J").Select
Columns("A:J").EntireColumn.AutoFit
Range("E:E,G:G").Select
Range("G1").Activate
Selection.NumberFormat = "0"
Range("A1").Select
End Sub
在此先感谢