0

Attempting to run the code below as a Script in Google Sheets. The goal is to be able to use the onEdit Trigger

Unfortunately, the code below is giving a:

TypeError: Cannot read property 'range' of undefined
onEdit  @ Code.gs:4

Error

function onEdit( e )
 {
  var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("FXKLog")
  var sh=e.range.getSheet();
  var range = e.getRange();

 }

What is the problem?

Any help, hints or advice would be greatly appreciated.

TIA

Casey Harrils
  • 2,793
  • 12
  • 52
  • 93
  • 2
    From `TypeError: Cannot read property 'range' of undefined`, in your script, when you directly run your script, I think that such an error occurs because of no event object `e`. If you want to achieve `The goal is to be able to use the onEdit Trigger`, please edit a cell. By this, your script is run by the OnEdit trigger. – Tanaike Sep 30 '22 at 02:24
  • I know my question has been closed but this helped too: https://www.youtube.com/watch?v=KC7pBjD3GGw – Casey Harrils Sep 30 '22 at 03:06

0 Answers0