I can't seem to figure out how to get my script to trigger only on the edit of specific cells and on the current sheet. I've tried just about everything and it just refuses to run the script at all if I change anything.

I've created new variables to try and select the specific cells, then trigger with an if statement all to no avail. The script below is the only current version I have working which triggers should I edit anything anywhere.

Please someone help me out, I've no idea what I've done wrong.

Edit: Updated the code I've been trying... Still not doing anything.

function onEdit(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var r  = sheet.getRange("D11");

if (r == 'Hide'){



3 Answers 3


Add getValue() to var r = sheet.getRange("D11");. The resulting code line is:

var r  = sheet.getRange("D11").getValue();

The above because getRange returns Range object which not return directly it's value/values.

Also replace r.hideRows(11); by sheet.hideRows(11);

For further details checkout https://developers.google.com/apps-script/guides/sheets

  • 1
    Reloaded the document and it's working! Thanks mate!
    – dcuttridge
    Commented May 31, 2019 at 0:13

I tried this and its actually worked .

function onEdit(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var r  = sheet.getRange("L2").getValue();

if (r == 'ADD'){

// Add your code here
  • try it like this

    function onEdit(e) {
    var s = SpreadsheetApp.getActiveSheet();
    if( s.getName() == "Checklist" ) {        // sheet name
    var r = s.getActiveCell(); 
    if( r.getColumn() == 3 ) {                // column number

    your script here


  • No luck. Same issue I was having where nothing happened at all. No errors, just nothing happens. Also, I've already got the column selected, but trying to select specific cells e.g. C6 so that it only triggers when those cells are edited.
    – dcuttridge
    Commented May 30, 2019 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.