I feel like there is perhaps an obvious answer. When I'm running this code:
function searchQuery() {
var compiledParticipantsSheet = spreadSheet.getSheetByName('Participants');
var participantsSheetLr = compiledParticipantsSheet.getLastRow();
var participantsSheetLc = compiledParticipantsSheet.getLastColumn();
var querySheet = spreadSheet.getSheetByName('Query');
var querySheetLr = querySheet.getLastRow();
var querySheetLc = querySheet.getLastColumn();
var data = querySheet.getRange(3, 1, querySheetLr, querySheetLc).getValues();
for (j = 2; j <= participantsSheetLr; ++j) {
var val = compiledParticipantsSheet.getRange(j, 2, 1, 1).getValue();
console.log('Searching Query sheet for row ' + j + ' -- ' + val)
for (i = 0; i < data.length; ++i) {
if (data[i][4] == val) {
var foundData = (data[i][20]);
console.log('------ Found email in query row ' + (i + 3) + ' = ' + foundData);
compiledParticipantsSheet.getRange(j, 11, 1, 1).setValue(foundData);
}else{
compiledParticipantsSheet.getRange(j, 11, 1, 1).setValue('Participant not found');
}
}
}
}
It runs painfully slow, but if I remove the one else statement at the end it runs super fast! Is that reasonable? Am I missing something? Thanks!