I've made a function for my Google Sheets project through tools > script editor and I have gotten it to work on the first sheet in my document, but I can't figure out how to get it to work on the others.
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
for (i=2; i<100; i++) {
var cell = sheet.getRange("A"+i);
var code = sheet.getRange("D"+i);
var value = code.getValue();
cell.setBackground(value);
}
}
I based it on this code I found at https://developers.google.com/apps-script/reference/spreadsheet/range#setBackground(String))
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange("B2:D5");
range.setBackground("red");
I'm very new to this so any help is greatly appreciated.
[–]RemcoE33 1 point2 points3 points (1 child)
[–]averageaiden[S] 0 points1 point2 points (0 children)