In Google Sheets, I would like to change the cell value (in this case to add text) based on the cell's background color. For example, if the cell's background color is green (#62a84f) as in the picture attached, I would like to automatically insert text "g" in the cell. Please see the picture I found the following script but cannot figure out how to get it working:
function myFunction() {
var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Prosinec+Leden");
var data1 = sheet1.getDataRange().getValues(); //2D array of sheet1 cell values
var bg;
for(var i=1; i<data1.length; i++)
{
bg = sheet1.getRange(?).getBackground();
if(bg == "#62a84f")
{
sheet1.getRange(?).setValue("x"); //Set value in corresponding row of sheet1
}
}
}
*Little background info - I work in an elementary school where we evaluate the progress of our pupils every week and it would save us a lot of work to have this script work.