我有以下宏,并希望减少行数以加快进程。
5
ActiveCell.Columns("A:A").EntireColumn.Select
If Selection.Find(What:="*", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=True) Is Nothing Then
GoTo 6
End If
Selection.Find(What:="*", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=True).Activate
ActiveCell.Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
GoTo 5
我想使用Offset用一行替换多个'Selection.Insert Shift:= xlToRight'行。
你能帮忙吗?
答案 0 :(得分:1)
将您的x5 Selection.Insert Shift:=xlToRight
替换为Range(ActiveCell, ActiveCell.Offset(0, 4)).Insert shift:=xlToRight
修改强>
与您的代码更相关:Range(Selection, Selection.Offset(0, 4)).Insert shift:=xlToRight