Concatenate Worksheets in Google Spreadsheet to new worksheet -
i have google spreadsheet contains multiple worksheets. worksheets have same columns have additional columns. concatenate worksheets single, newly created worksheet in same workbook. differences in columns should contain blank values.
bonus points if adapted use on multiple workbooks. preferable if select sheets concatenate.
i have tried write script struggling.
the mother of sheets
you of spreadsheets in drive , of them well. i'm not doing it. allows include sheets want concatenated adding them array includedsheet.
function concatallsheets() { var includedsheet=['sheet1','sheet2','sheet3']; var ss=spreadsheetapp.getactive(); var allsheets=ss.getsheets(); var sheetname='motherofallsheets-' + utilities.formatdate(new date(), session.getscripttimezone(), "yyyymmddhhmm") var mother=ss.insertsheet(sheetname); for(var i=0;i<allsheets.length;i++) { var sht=allsheets[i]; if(includedsheet.indexof(sht.getname())>-1) { var rng=sht.getdatarange(); var rnga=rng.getvalues(); for(var j=0;j<rnga.length;j++) { var row=rnga[j]; mother.appendrow(row); } } } }
Comments
Post a Comment