I've just started dabbling in VBA for Google Sheets and have written a script, however, it's insanely slow, is this due to a mistake below or is there a way of speeding it up ?
The point of this script is to have 3 work tabs and one mastersheet to save the data each day. Once all the VLookUps are set, I'll copy and paste them as values, but so far the loop is way too slow to even consider using it.
function autoJ7(){
var masterSheet= SpreadsheetApp.getActive().getSheetByName('New Accounts Q4');
var masterLength = masterSheet.getLastRow();
for(var row = 1; row < masterLength; row++){
var rowPath=masterSheet.getRange(row,8).getValue();
if(rowPath<6) {}
else if(rowPath<13) {
masterSheet.getRange(row,16,1,1).activate().setFormula("=vlookup(A"+row+",\'J+7\'!A:M,13,0)");
Logger.log("Path A");
}
else if(rowPath<20) {
masterSheet.getRange(row,17,1,1).activate().setFormula("=vlookup(A"+row+",\'J+14\'!A:M,13,0)");
Logger.log("Path B");
}
else if(rowPath<42) {
masterSheet.getRange(row,18,1,2).activate().setFormula("=vlookup($A"+row+",\'J+21\'!$A:$M,13,0)");
Logger.log("Path C");
}
};