i have access db i'm trying copy several worksheets in single folder master excel file
i first build array of file locations called filedetails
workbooks , open each 1 , paste contents master file. because don't want files pasting on each other. starting location on master workbook offset of 1 previous pasting location. workbooks in same working directory code set stop main workbook being copied itself
the code fails @ xlsht2.range(selection, selection.end(xltoright)).select
error message
run-time error '424' object required
set xlapp = createobject("excel.application") '## open working file set xlbook_a = xlapp.workbooks.open(strwf) set xlsht = xlbook_a.worksheets(1) ' open each sheet , copy workbook (except worksheet itself) intrecord = 1 ubound(filedetails) if (filedetails(1, intrecord)) <> strwf set xlbook_b = xlapp.workbooks.open(filedetails(1, intrecord)) set xlsht2 = xlbook_b.worksheets(1) ' after rows have been pasted, new starting point not "a2" need set ' offset done after each copy , paste giving append operation ms excel ' sheet wont overwrite sheet b xlsht2.range(selection, selection.end(xltoright)).select xlsht2.range(selection, selection.end(xldown)).select xlsht2.selection.copy destination:=xlsht.range("a1").end(xldown).offset(1, 0) end if next intrecord
can see im going wrong?
in code, remove 3 lines before endif , include this
xlsht2.range(selection, selection.end(xltoright)).select if xlsht.range("f1").end(xldown).row=rows.count xlsht2.range(selection, selection.end(xldown)).copy xlsht.range("f1") else xlsht2.range(selection, selection.end(xldown)).copy xlsht.range("f1").end(xldown).offset(1, 0) endif
Comments
Post a Comment