3
votes

I would like a run a macro when a specific cell is changed in a google sheet. I have found very similar scripts but they tend to require a user to enter specific text in a specific cell. In my script, i only want to run a macro when the value changes in E2.

Essentially, its like the default OnEdit, but for 1 cell, not the whole sheet.

I have this so far

function onEdit(e) {
if(e.range.getA1Notation() !== 'E2' || e.value !== '') return;
movetog82()
}

my macro is called 'moveto82'

In e.value, i have left this blank but not sure what to substitue this with for it to capture any cell change.

1

1 Answers

1
votes

You don't need any e.value comparison at all, just run the contents of the condition if the changed range is 'E2':

function onEdit(e) {
   if(e.range.getA1Notation() == 'E2'){
     movetog82()
  }
}

Any time 'E2' is edited it'll run movetog82(), else nothing will happen.