excel - Copying a column to a new workbook sheet in VBA -
i trying copy existing column sheet column in new workbook.
the code tried:
set newbook = workbooks.add sheets("sheet1").columns(1).copy destination:=newbook.sheets("sheet1").columns(2)
this creating sheet no values copied! code works if copy sheet in same workbook.
how should create new sheet in newbook
, target columns in sheet
?
you must remember old book, otherwise sheets("sheet1").columns(1)
refer first column of sheet1
of newly added 1 since activeworkbook
in moment (so copy something, empty column):
sub qwerty() set w1 = activeworkbook set newbook = workbooks.add w1.sheets("sheet1").columns(1).copy destination:=newbook.sheets("sheet1").columns(2) end sub
edit#1:
this rename sheet in new workbook , perform copy:
sub qwerty2() set w1 = activeworkbook set newbook = workbooks.add activesheet.name = "report" w1.sheets("sheet1").columns(1).copy destination:=columns(2) end sub
Comments
Post a Comment