r/GoogleAppsScript • u/deftPirate • Aug 15 '25
Question First experience scripting, kind of lost
I followed a youtube tutorial (this one) to put together a script hoping to make a button that would check/uncheck certain sets of boxes on a sheet.
Differences I'm certain of:
The tutorial used a specific named sheet for const ws = ss., where I used getActiveSheet
- This is because if the button works, I'll want to create a handful more sheets with identical layouts but different values, each with the same columns of boxes to check/uncheck
The tutorial had a different setup for the range of boxes, something like "the whole column minus one".
- I tried to adapt this because I would like to be able to check/uncheck boxes across multiple columns with one button.
The test run produces this error and, to be blunt, I have no idea what it means. Is it "not a function" because of the notation I did for the multiple columns? Or is ws.getRange itself wrong somehow?
View all comments
Show parent comment
1
u/deftPirate Aug 16 '25
That definitely helped things click. I expect to mainly check boxes manually, and uncheck them en masse with the button. This is the result that worked for the sheet:
function checkBoxes(check) { const ss = SpreadsheetApp.getActiveSpreadsheet() const ws = ss.getActiveSheet() ws.getRange(2,3,6).setValue(check); ws.getRange(2,6,13).setValue(check); ws.getRange(2,9,13).setValue(check); ws.getRange(2,12,13).setValue(check); ws.getRange(2,15,13).setValue(check) }
function checkAllBoxes() { checkBoxes(true)
} function uncheckAllBoxes() { checkBoxes(false)
}
If it wasn't clear, I had totally winged it on the original .getrange function, so after your example and looking up the parameters I could see what needed to happen. Thanks again!