0
function onEdit(if getActiveRange()=A3:B500) {//Check to see if the cells edited are on this 
    rangemyFunction1(event);// trying to set off this function that has other functions nested
player0
  • 124,011
  • 12
  • 67
  • 124
  • Is this the whole code? Where is rangemyFunction1? Why do you have an if in the parameter section of the function? – Robin Gertenbach Jan 29 '20 at 17:31
  • 1
    is this a copy/paste from your actual code? The script editor will not even allow you to save a script with the syntax as presented, this isn't valid Javascript syntax. I can help you rewrite it, but want to be sure there isn't just a typo or copy/paste error in the question as presented. – Cameron Roberts Jan 29 '20 at 17:33
  • Its copy of the actual code i just couldnt get it to work, i was trying to make it check for edit on this specific range A:B columns and then execute some code – thebestcanoftuna Jan 29 '20 at 19:15

1 Answers1

0

Question

Why my code is not working?

Answer

Wrong javascript syntax

Your code is not working because your JavaScript syntax is wrong because you can't write if statement inside parameters.

function onEdit(if getActiveRange()=A3:B500) {//Check to see if the cells edited are on this 
    rangemyFunction1(event);// trying to set off this function that has other functions nested

Instead you have to write something like this:

function onEdit() {
    if (getActiveRange() === "A3:B500") {
        rangemyFunction1(event);
        // do more stuff
    }
    // do other stuff
}

Check the onEdit example on developers.google.com

More examples here and here.

Jeff Rush
  • 874
  • 6
  • 13