How to use the onEdit(e) Function on Google Sheets

In the Post, I demonstrate how to use the onEdit(e) Function on Google Sheets. This video focuses on the editing of one cell.

How to Video:

Video Notes:

  • Legacy Apps Script Editor Used in Video
  • Apps Script (Script Editor) is now located under tab ‘Extensions’ instead of ‘Tools’ on Google Sheets

Code in Video:

function onEdit(e) {
  
  var range = e.range;
  var spreadSheet = e.source;
  var sheetName = spreadSheet.getActiveSheet().getName();
  var column = range.getColumn();
  var row = range.getRow();
  var inputValue = e.value;
  
  if(sheetName == 'ONEDIT' && column == 1 && row == 1)
  {  
     SpreadsheetApp.getActiveSpreadsheet().getSheetByName('ONEDIT').getRange('A2').setValue([inputValue]);    
  } 
}

Related Posts

How to use the onOpen(e) Function on Google Sheets - In this post, I show how to use the Google Apps Script onOpen(e) Trigger Function on Google Sheets. I show two examples of how the function can be used.
On Selection Change Google Sheets Copy Row Using onSelectionChange(e) Trigger on Google Sheets - In this post, I demonstrate how to use the onSelectionChange(e) trigger function in an application that copies Rows from one sheet to another.
doGet(e) Function Google Script How to Use doGet(e) Function to Start HTML Google Web App - In this post, I show three different examples of how to use the doGet(e) function to start the HTML Google Web Application.

Leave a Reply