I'm managing a Google spreadsheet with a script. onEdit is working - I can colour a cell red by putting
SpreadsheetApp.getActiveRange().setBackgroundRGB(255, 0, 0);
in the onEdit function. I would like to put the same code in a onClick function, so that when a user clicks on a cell it immediately turns red. Is this possible? I can't find any way to do it in the documentation.
As stated on the comments above before there's no way (right now) to create an onClick()
function for Google Spreadsheets. That makes sense due to the fact that the google app script functions are processed in the server, the amount of load generated by onClick()
events execution would make pretty easy to deplete all the quota of requests provided by default.
You should be using the documentation for creating a button and clicking on it.
You can get closer....Create a validation for the cells with an option...like "Done". Click the dropdown, select Done. now create a trigger onChange or onEdit to fire. You can get a cell/range contextualized function....like firing on a row or column. This is easy to replicate and program for
You can add a Drawing as a button - https://developers.google.com/apps-script/guides/menus#clickable_images_and_drawings_in_google_sheets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With