Excel VBA: Select the column next to the column with data and then insert 3 columns -
sub new activesheet.range(“c9”).end(xlright).offset(1,0).select selection.insert shift:xltoright selection.insert shift:xltoright selection.insert shift:xltoright end sub
this doesn't work @ , gives me error. appreciated!
thanks!
you can replace entire code 1 line:
activesheet.range("c9").offset(0, 1).resize(, 3).entirecolumn.insert
the first part activesheet.range("c9").offset(0, 1)
select cell on right side of cell "c9".
the second part .resize(, 3).entirecolumn.insert
insert 3 columns @ once on right side (instead of repeating same line 3 times)
in case meant find last column in row 9 data, in range("c9").end(xlright)
, use code below:
with activesheet ' find last column data in row 9 lastcolumn = .cells(9, .columns.count).end(xltoleft).column .range(cells(9, lastcolumn), cells(9, lastcolumn)).offset(0, 1).resize(, 3).entirecolumn.insert end
Comments
Post a Comment