I manage a small sales team (currently 5 members but growing) who input sales data into multiple sheets within one workbook. I am looking to automate the process by running a script to merge all these sheets on a daily basis.
Here is the breakdown of the daily stages:
1) Clear all existing records from the Master Daily sheet (to ensure any updates or changes are accounted for from individual sales sheets) 2) Iterate through each sheet and consolidate the data
There are 6 columns, all in the same order but with different data values.
Edit Open until bounty awarded.
Code snippet attempt :
function merge() {
var v, arr,
ss = SpreadsheetApp.getActive();
ss.getSheets().filter(function(s) {
return s.getName()
.indexOf('Project') > -1
}).forEach(function(s, i) {
v = s.getDataRange()
.getValues()
.filter(function(r) {
return r.toString()
.length > 0
})
arr = (i == 0) ? v : arr.concat(v);
})
ss.getSheetByName('Master')
.getRange(1, 1, arr.length, arr[0].length)
.setValues(arr);
}
Any assistance would be greatly appreciated.
Thank you!