I have a sheet with checkboxes in the first column. I would like to be able to trigger a function by checking a box. Right now all the checkboxes are set to false/unchecked. Is there anyway to trigger an event by checking a box?
Asked
Active
Viewed 1.3k times
7
-
3See [Triggers](https://developers.google.com/apps-script/guides/triggers/#onedite) – Chris Feb 28 '19 at 22:38
-
1Is this thread useful for your situation? https://stackoverflow.com/q/54856739/7108653 – Tanaike Feb 28 '19 at 23:15
-
Possible duplicate of [onEdit() doesn't catch all changes](https://stackoverflow.com/questions/54856739/onedit-doesnt-catch-all-changes) – Rubén Mar 01 '19 at 04:09
-
This is interesting. I see that the event can have a range. Is there information on which sheet in a spreadsheet that generated it? – user1592380 Mar 01 '19 at 16:51
-
@user61629 Although I'm not sure whether I could correctly understand your comment, if ``function onEdit(e) {}`` is used, the spreadsheet ID and the edited sheet name can be retrieved by ``e.source.getId()`` and ``e.source.getSheetName()``, respectively. – Tanaike Mar 01 '19 at 23:22
-
1Yes , that's what I wanted to know. Thank you. – user1592380 Mar 02 '19 at 14:31
-
@user61629 I'm glad your issue was resolved. By the way, can you post it as an answer and accept it? By this, other users can see your question as the resolved question. – Tanaike Mar 02 '19 at 23:22
-
@Tanaike, I've entered an answer, but I don't think it adds anything not in the other threads. I'm still trying to decide what to do next. – user1592380 Mar 03 '19 at 18:38
-
@user61629 Thank you for replying. I apologize for my comment. – Tanaike Mar 04 '19 at 22:24
2 Answers
10
The following is not much of an answer, but does log ONEDIT when clicking or unclicking a checkbox. Maybe it can be used as a start for something more complicated.
function onEdit(e){
if (e.range.columnStart == 1 && e.range.columnEnd == 1 && e.range.rowStart <= 2000) {
Logger.log('ONEDIT');
}
}

user1592380
- 34,265
- 92
- 284
- 515
-
Yes, see: https://stackoverflow.com/questions/12583187/google-spreadsheet-script-check-if-edited-cell-is-in-a-specific-range – Magne May 21 '20 at 15:38
-3
When you Insert a checkbox, the cell value can either be true or false. So, in my opinion, create a function "status_check" and do the following:
- Create a Trigger which executes status_check function every minute.
- Insert an "IF" condition, if the status of the cell is false, then do nothing.
- if "IF" is true then execute the necessary code.
This will work seamlessly with lag of just a minute.

Anshul Bansal
- 41
- 1
- 2