Using a google sheets apps script, Is it possible to get the X cell in a range of cells as shown below:
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var cells = sheet.getRange("D6:BF100"); // the range
for (var x = 0; x < 100; i++) {
var cell = cells[row][x]; // this is the line that doesn't work
if (someCondition(x)) {
cell.setBackground("red");
}
}
I don't want to change the colors for every single cell, just the ones that have the correct condition.
I know it is possible to do something like this:
var cell = sheet.getRange(row+i);
But this method takes a very long time to complete the for loop as there are hundreds of cells that need to be scanned. I would rather only use getRange once with the entire range (instead of just one cell at a time) and then from that range (it should make a 2d array right?) set the cell values. I think that would be a lot faster.
Is there a different way to do it faster, or do I just need to do this: var cell = cells[row][x];
a different way.
Thanks!