This is the function I want to be triggered when On edit (Spreadsheet 1)
function sendData()
{
var value1=SpreadsheetApp.getActiveSheet().getActiveRange().getValue();
SpreadsheetApp.openById("third spreadsheet ID").getSheetByName("***").getRange("B2").setValue(value1);
}
From another spreadsheet (2) I wrote down:
function TriggerOn()
{ // create trigger
var spreadsheet = SpreadsheetApp.openById("first Spreadsheet ID");
ScriptApp.newTrigger("senData").forSpreadsheet(spreadsheet).onEdit().create();
}
But it doesn't work because forSpreadsheet(spreadsheet) only works on the same spreadsheet...
If you refer to the doc, the argument for .forSpreadsheet() is the ID of the spreadsheet, not the spreadsheet itself.
try this instead :