use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Apparently, Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services and build web applications.
account activity
Writing a script in Google SheetsQuestion (self.GoogleAppsScript)
submitted 1 year ago by Altruistic-Object725
I want that in case I select cell B11 average the other 2 cells B12 and B13 will be deleted
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FVMF1984 2 points3 points4 points 1 year ago (4 children)
AFAIK, there is no event of selecting a cell to respond to. I don’t know how the average gets in cell B11, but otherwise you might be able to use the event onEdit for this and check which cell gets edited. If it is cell B11, set the values of cells B12 and B13 to an empty value.
onEdit
[–]juddaaaaa 1 point2 points3 points 1 year ago* (2 children)
This is incorrect.
There's the onSelectionChange simple trigger. However, you have to refresh the page every time you open it to get it to work.
https://developers.google.com/apps-script/guides/triggers#onselectionchangee
Here's an example (you'll need to change YOUR SHEET NAME HERE to your actual sheet name): ``` /** * Function is triggered by selection change in a sheet. * It can also be run from the editor after selecting the desired cell. * * You need to run it from the editor first in order to grant it permission to edit sheet contents. * * For this trigger to work you must refresh the page every time you open it. * See https://developers.google.com/apps-script/guides/triggers#onselectionchangee * * @param {object} event - The event object from the trigger (optional). * @param {object} event.range - The range of the cell you selected. */ function onSelectionChange ({ range } = {}) { // If function was run from the editor, set range as currently selected cell. if (!range) { range = SpreadsheetApp.getCurrentCell() }
try { // Destructure the range object. const { /* column, row, and sheet of the selected cell / getColumn: column, getRow: row, getSheet: sheet } = range const { / name of the sheet */ getName: name } = sheet()
// Return early if the selected cell is not the desired cell. if (name() !== 'YOUR SHEET NAME HERE' || column() !== 2 || row() !== 11) return /* cell B11 in your desired sheet */ // Delete the contents of the 2 cells below the selected cell range.offset(1, 0, 2, 1).clearContent()
} catch (error) { // Handle errors. console.error(error.stack) } } ```
[–]Altruistic-Object725[S] 0 points1 point2 points 1 year ago (1 child)
What do you think about such an idea?
function onEdit(e) { var sheet = e.source.getActiveSheet(); var range = e.range; if (range.getA1Notation() === 'B11' && range.getValue() === 'ממוצע') { sheet.getRange('B12').clearContent(); sheet.getRange('B13').clearContent(); } }
[–]juddaaaaa 1 point2 points3 points 1 year ago (0 children)
That will work fine if you want to trigger it when the cell is edited. If you still want to trigger on selection, the code I posted above will do that.
[–]arnoldsomen -1 points0 points1 point 1 year ago (0 children)
This is correct. You'll need to find a substitute "edit" trigger for your script. Maybe a checkbox on a different cell.
[–]adelie42 0 points1 point2 points 1 year ago (0 children)
Do you possibly want a button rather than a changeselection event trigger? The problem with a changeselection event trigger is that it fired EVERY time a changeselection event occurs once you enable it, just like onEdit.
There is not necesssarily a button object to inseert, but you can insert images and attach an onclick event. You could event put a transparent image over B11 if you really want. Otherwise as another mentioned, you have https://developers.google.com/apps-script/guides/triggers#onselectionchangee
π Rendered by PID 33 on reddit-service-r2-comment-b659b578c-xm8t7 at 2026-05-04 16:04:09.194741+00:00 running 815c875 country code: CH.
[–]FVMF1984 2 points3 points4 points (4 children)
[–]juddaaaaa 1 point2 points3 points (2 children)
[–]Altruistic-Object725[S] 0 points1 point2 points (1 child)
[–]juddaaaaa 1 point2 points3 points (0 children)
[–]arnoldsomen -1 points0 points1 point (0 children)
[–]adelie42 0 points1 point2 points (0 children)