inserting more than one column

  • Thread starter Thread starter SITCFanTN
  • Start date Start date
S

SITCFanTN

What would the VBA code be to insert 6 columns to the left of Col A? I
recorded a macro but I know there has to be a quick line of code that will do
the same things rather than 10 lines of code from the macro recorder. Thank
you.
 
Hi

Columns("A:F").Insert Shift:=xlToRight

--
Regards
Roger Govier

SITCFanTN said:
What would the VBA code be to insert 6 columns to the left of Col A? I
recorded a macro but I know there has to be a quick line of code that will
do
the same things rather than 10 lines of code from the macro recorder.
Thank
you.

__________ Information from ESET Smart Security, version of virus
signature database 4751 (20100107) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4751 (20100107) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
The generalize form of Roger's statement would be this...

NumberOfCols = 6
Columns("A").Resize(,NumberOfCols).Insert Shift:=xlToRight

where you can set a variable number of columns to insert, as needed. Make
sure you note the comma in front of the variable named NumberOfCols inside
the Resize property call.
 
Back
Top