Excel append all rows with data into master-sheet -
i not know vb searched , copied macro accomplish need append rows data sheets in same workbook starting row 10 master-sheet. need modify macro data appended master sheet starting row 10 because in rows 1-9 there headings.
sub copydatawithoutheaders() dim sh worksheet dim destsh worksheet dim last long dim shlast long dim copyrng range dim startrow long application .screenupdating = false .enableevents = false end 'delete sheet "rdbmergesheet" if exist application.displayalerts = false on error resume next activeworkbook.worksheets("rdbmergesheet").delete on error goto 0 application.displayalerts = true 'add worksheet name "rdbmergesheet" set destsh = activeworkbook.worksheets.add destsh.name = "rdbmergesheet" 'fill in start row startrow = 10 'loop through worksheets , copy data destsh each sh in activeworkbook.worksheets 'loop through worksheets except rdbmerge worksheet , 'information worksheet, can ad more sheets array if want. if iserror(application.match(sh.name, _ array(destsh.name, "information"), 0)) 'find last row data on destsh , sh last = lastrow(destsh) shlast = lastrow(sh) 'if sh not empty , if last row >= startrow copy copyrng if shlast > 0 , shlast >= startrow 'set range want copy set copyrng = sh.range(sh.rows(startrow), sh.rows(shlast)) 'test if there enough rows in destsh copy data if last + copyrng.rows.count > destsh.rows.count msgbox "there not enough rows in destsh" goto exitthesub end if 'this example copies values/formats, if want copy 'values or want copy below example 1 on page copyrng.copy destsh.cells(last + 1, "a") .pastespecial xlpastevalues .pastespecial xlpasteformats application.cutcopymode = false end end if end if next exitthesub: application.goto destsh.cells(1) 'autofit column width in destsh sheet destsh.columns.autofit application .screenupdating = true .enableevents = true end end sub could please give me indications on change start pasting row 10?
it seems code determines last row in destsh custom function called lastrow. therefore seem need change in function in order avoid override of initial 10 first rows.
although not know data looks like, expect avoid using lastrow function , instead replase line with destsh.cells(last + 1, "a") line:
with destsh.cells(destsh.cells(rows.count, 1).end(xlup).row + 1, "a") this find last empty row of column a in destsh , paste copied range there.
Comments
Post a Comment