I have 140 separate sheets and counting to merge into one separate sheet. The usual importrange or arrays etc are too much for the number of sheets I have to merge.
The heading row on each sheet is the same so I just need all the data in each sheet from row 3 onwards to be copied into the new master sheet. The amount of data in each is variable. I don't mind copying everything including the headings as I can delete them manually with a filter.
I found this code (https://ctrlq.org/code/19980-merge-google-spreadsheets) which I ran and I keep getting the error - Missing ) after argument list. (line 4, file "Code")
I set the SOURCE to the folder key where all the files I want to merge are kept. I'm new to writing scripts:
function mergeSheets() {
/* Retrieve the desired folder */
var myFolder = DriveApp.getFoldersByName(SOURCE).next();
/* Get all spreadsheets that resided on that folder */
var spreadSheets = myFolder.getFilesByType("application/vnd.google-apps.spreadsheet");
/* Create the new spreadsheet that you store other sheets */
var newSpreadSheet = SpreadsheetApp.create("Merged Sheets");
/* Iterate over the spreadsheets over the folder */
while(spreadSheets.hasNext()) {
var sheet = spreadSheets.next();
/* Open the spreadsheet */
var spreadSheet = SpreadsheetApp.openById(sheet.getId());
/* Get all its sheets */
for(var y in spreadSheet.getSheets()) {
/* Copy the sheet to the new merged Spread Sheet */
spreadSheet.getSheets()[y].copyTo(newSpreadSheet);
}
}
}
Could anyone tell me what the error means? I'm not missing any ). I suspect the problem is how I've defined the SOURCE?
Thanks