excel vba - Consolidation of data from all worksheet to summary work sheet -
i want copy data worksheets summary worksheet. in summary worksheet first column "description". can copy worksheet, next column numbers each worksheet specific column. want through input box. both description , numbers. please me modify below code. example: description copied worksheet input box, standard (need not copy worksheet, 1 worksheet enough), , next columns copied each worksheet input box
sub consolidation() dim sh worksheet dim destsh worksheet dim lr long dim copyrng range dim lcolumn long application .screenupdating = false .enableevents = false end ' delete summary sheet if exists. application.displayalerts = false on error resume next activeworkbook.worksheets("mergesheet").delete on error goto 0 application.displayalerts = true ' add new summary worksheet. set destsh = activeworkbook.worksheets.add destsh.name = "mergesheet" ' loop through worksheets , copy data ' summary worksheet. each sh in activeworkbook.worksheets if sh.name <> destsh.name ' find last column data on summary worksheet. 'last = lastcolumn(destsh) lcolumn = destsh.cells(1, columns.count).end(xltoleft).column lr = sh.range("b" & rows.count).end(xlup).row ' specify range place data. set copyrng = sh.range("b1:c" & lr) ' statement copies values , formats each ' worksheet. copyrng.copy destsh.cells(1, lcolumn + 1) .pastespecial xlpastevalues .pastespecial xlpasteformats application.cutcopymode = false end end if next exitthesub: application.goto destsh.cells(1) ' autofit column width in summary sheet. destsh.columns.autofit application .screenupdating = true .enableevents = true end end sub
Comments
Post a Comment