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/mommasaidmommasaid Aug 17 '25 edited Aug 17 '25
FWIW if you need specific ranges like this, I would specify them in A1 notation to make it easier to read. And build them from a single string to make it more convenient to edit, e.g.:
It's also generally better to do things with with as few get/set functions as possible (although multiple setValue() calls do seem to get batched).
That can done by building a range list and operating on that:
Here's an example triggered from a trigger checkbox with a custom "true" value:
Uncheck on Trigger
Conditional formatting is used to highlight the trigger checkbox when it's "true" so the user gets immediate feedback while the script is firing up. Script unchecks the trigger checkbox when done.
The script does a little extra fanciness activating the ranges that are being unchecked to provide a visual progress / verification.
There are two versions, one which clears a hardcoded range (if you want the same range on each sheet) and another that allows specifying the range as part of the checkbox custom value. The latter avoids hardcoding anything but the trigger checkbox value in the script.