I need to do a 2 way sync between 2 spreadsheets and I found this solution.
Here is the script from the link above. And yes, I did modify "TheSheetNameToCheck" and targetFile/targetSheet.
//Author: RemcoE33
function onEdit(e) {
const sheet = e.source.getActiveSheet();
const range = e.range;
const value = e.value;
if (
sheet.getName() == 'TheSheetNameToCheck'
&& range.getColumn() >= 5
&& range.getColumn() <= 31
&& range.getRow() >= 14
&& range.getRow() <= 20
) {
const targetFile = SpreadsheetApp.openById('1hVcBM7Tzkg40YxxxxxxxxxF3prATgF8')
const targetSheet = targetFile.getSheetByName('TheSheetNameToCheck')
const a1 = range.getA1Notation()
targetSheet.getRange(a1).setValue(value)
}
}
The issue is that when I run the script, I get an error message "TypeError: Cannot read property 'source' of undefined" and I'm not sure how to proceed.