偏移与Selection.Insert Shift:= xlToRight相比

时间:2014-02-13 16:01:54

标签: excel vba excel-vba

我有以下宏,并希望减少行数以加快进程。

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'行。

你能帮忙吗?

1 个答案:

答案 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