VBA -Column Insertion code Optimization

I am trying to Insert a column in the Worksheet,

Here Goes my code,

 Sheets(Currentsheetname).Range("A" & MyRow & ":B" & lastrow).Select
 .Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

Is there a way to run this code, a bit faster. At the moment it is taking anything between 5-10 seconds.

Thanks.

Upvotes: 1

Views: 45

Answers (1)

braX
braX

Reputation: 11755

This should be faster: (never use Select and Selection)

Sheets(Currentsheetname).Range("A" & MyRow & ":B" & lastrow).Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

Upvotes: 4

Related Questions