How to Automatically Change a Cell in Google Sheets Based on Multiple Variables -
i working on creating schedule in google sheets , have 1 last task cannot figure out. here example of accomplish.
for lines 8-12 (which employees 1-5) need have script looks every cell contains either or a-10. if these or a-10 shifts fall on 1-15 (days of month in row 5...pictured below) should changed aa or aa-10. if fall on 16th-end of month should ap or ap-10. same case r , shifts.
here screen shot of google sheet example gave above:
any appreciated! thanks!
here script changes. changes rows 8 - 12 , assumes dates in row 5.
function changevalues() { var ss = spreadsheetapp.getactive(); var sheet = ss.getactivesheet(); var range = sheet.getrange("8:12"); var dates = sheet.getrange("5:5").getvalues(); var values = range.getvalues(); for(var row = 0; row < values.length; row++) { for(var column = 1; column < values[row].length; column++) { var day = number(dates[0][column].replace(/[^0-9]/g, "")); var value = values[row][column]; if(day >= 1 && day <= 15) { if(value === "a") value = "aa"; else if(value === "a-10") value = "aa-10"; } else if(day > 15) { if(value === "a") value = "ap"; else if(value === "a-10") value = "ap-10"; } values[row][column] = value; } } range.setvalues(values); }
Comments
Post a Comment