Without examples and context, titling this was quite challenging. Here goes...
I've created a Google Apps Script that searches through a column of student IDs (specifically in column A on the compiledDATA sheet) and assigns an award value to column B of the same row. While this works for a single student ID, I now require the script to iterate through and assign the same award value to all students within the GroupAwardIDs range located on a separate sheet called Group Awards.
For reference, here's a link to my sample spreadsheet: sample spreadsheet.
The values needing assignment are nonconsecutive, with potentially over a thousand to be processed at once.
How can I efficiently achieve this without hitting quota limits?
Below is the script (apologies for the numerous comments - they help me stay organized):
function AwardGroup() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var StarLog = sheet.getSheetByName("compiledDATA");
var GroupAward = sheet.getRangeByName("GroupAward").getValue();
var GroupAwardIDs = sheet.getRangeByName("GroupAwardIDs").getValue(); // THESE ARE THE IDS OF STUDENTS WHO WILL RECEIVE THE AWARD. HOW DO SET VALUES FOR ALL AND ONLY THESE IDS?
var IDs = sheet.getRangeByName("StudentIDs").getValues(); // all of the student IDs
for (var i = 0; i < IDs.length; i++) {
if (IDs[i] == "123461") { // THIS WORKS IF HARDCODE A SINGLE ID
var rowNumber = i+3; // find row and add 3 to compensate for GroupAward range staring at row 3
var StarLogCurrent = StarLog.getRange("B"+rowNumber).getValue(); // locates students award log cell using A1 notation
var appendAward = GroupAward.concat(StarLogCurrent); // prepends new award to previous awards
StarLog.getRange("B"+rowNumber).setValue(appendAward); //write new star log
}
}
}