Excel VBA Insert copied cells and shift cells down ERROR -
complete amateur here. i've been puzzling on hours, , can't find me in other thread. @ wit's end sorry if has been asked elsewhere.
i'm trying create ridiculously simple macro following:
go sheet2, select c6:c10 copy go sheet3 insert copied cells in b2 , shift other cells down.
i did recording macro, each time it, different errors. error have 'insert method of range class failed', error pops @ 'selection.copy'. code have:
sub insertcellsshitdown() ' ' insertcellsshitdown macro ' ' sheets("booking sheet").select range("c6:c10").select selection.copy sheets("sheet1").select range("b2").select selection.insert shift:=xldown end sub
any hugely appreciated.
sub insertcellsshiftdown() ' ' insertcellsshitdown macro dim bookingws worksheet, mainws worksheet dim copyrng range set bookingws = sheets("booking sheet") set mainws = sheets("sheet1") set copyrng = bookingws.range("c6:c10") mainws.range("b2:b" & copyrng.rows.count + 1).insert shift:=xldown copyrng.copy mainws.range("b2") end sub
how work? assume wanted insert 5 rows, b2:b7
, put data.
Comments
Post a Comment