There is a Master worksheet, which needs to be populated by more than 75 child sheets with different values.
EDIT:
The situation has changed slightly.
'AGENTS'
Agent Name Sheet ID
1 Tom Link to Tom's sheet
2 John Link to John's sheet
3 Mary Link to Mary's sheet
etc.
links to:
'MASTER SHEET'
A C D
Agent Name Value 1 from Agent's Sheet Value 2 from Agent's Sheet
1 D46 D53
2 D46 D53
3 D46 D53
Also this is based on 1 cell which refers to the week no.
So if the cell F11 on the Master is ’39’ it would pull the data from the agent sheets from that particular week.
I have made a feeble attempt to alter the code to this:
var agentNames = SpreadsheetApp.getActive().getSheetByName('AGENTS').getRange('A2:A35').getValues();//these are the agent names
var agentID = SpreadsheetApp.getActive().getSheetByName('AGENTS').getRange('B2:B35').getValues();//here are their sheets
var agentSheets = SpreadsheetApp.openById(agentSheets[i][0]);
var array1 = [];
var array2 = [];
var array3 = [];
var masterSheet = SpreadsheetApp.getActive().getSheetByName('MASTER');
var sheetName = SpreadsheetApp.openById('B2') + 'F2' + (masterSheet.getRange('F11').getValue());
var temp;
for (var i = 0; i < numAgents; i++) {
temp = SpreadsheetApp.openById(agentSheets[i][1]).getSheetByName(sheetName).getRange('D46:D53').getValues();
array1.push([agents[i][0]]);
array2.push([temp[0][0]]);
array3.push([temp[7][0]]);
}
masterSheet.getRange(2, 1, numAgents, 1).setValues(array1);//Agent names
masterSheet.getRange(2, 3, numAgents, 2).setValues(array2);
masterSheet.getRange(2, 4, numAgents, 2).setValues(array3);
}
Would JavaScript be the next best solution for this issue? The loading times seem to be very long when the script runs for 75 or more sheets. Any suggestion or advice is welcome on how to proceed!
7My fairly simple advice would be, wherever possible, try to do your gets and sets in batches, and not within loops. So it is generally better to construct a Javascript array, and set it in one go. Below is my guess at some code: