google sheets onedit specific cell

Viewed 10229

In google sheets, I'm looking to have data copied from one sheet to another after editing a particular cell in the sheet being copied. I have code that does what I want except for only being trigger by the particular cell. Can anyone tell me what I'm missing?

function OnEdit(e) {


 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var destination = SpreadsheetApp.openById("1P6gj2UwfRmSMYZ4LBovvqbqy88aluOysPqWWhWbw_VE") 
 var source_sheet = ss.getSheetByName("Submit");
 var destination_sheet = destination.getSheetByName("Point Tracker");
 var source_range = source_sheet.getRange("A2:C2"); 
 var editedcell = source_sheet.getRange("C2"); 


 if(editedcell.getValue() !== 0){   

 var last_row = destination_sheet.getLastRow();
 destination_sheet.insertRowAfter(last_row);
 var destination_range = destination_sheet.getRange("A"+(last_row+1)+":C"+(last_row+1));
 source_range.copyTo(destination_range,{contentsOnly:true}); 
 source_sheet.getRange("C2").setValue("");

  }
}
2 Answers
Related