2014-02-13 144 views
1

我有以下的宏,並希望減少行數,以加快進程。偏移相比Selection.Insert Shift = xlToRight

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 

我想替換倍數「Selection.Insert換檔:= xlToRight」線路用單線使用偏移。

您能否請幫助!

回答

1

更換您的X5 Selection.Insert Shift:=xlToRight通過Range(ActiveCell, ActiveCell.Offset(0, 4)).Insert shift:=xlToRight

編輯

更多相關代碼:Range(Selection, Selection.Offset(0, 4)).Insert shift:=xlToRight

+0

這是完美的。 範圍(Selection,Selection.Offset(0,4))。插入移位:= xlToRight 是我的宏的正確代碼。非常感謝你。 –

+0

我很高興它幫助你。你能否將答案標記爲已接受,以便其他人知道問題已得到解答?謝謝。 – hstay