Continuing from previous question
This code recodes the last edited data from Spreadsheet A Sheet1 into the same Spreadsheet A Sheet2, but I want that data (Spreadsheet A Sheet1) to be added into another Spreadsheet B Sheet2
I couldn’t configure how to modify the code since it looks a little complex to me.
Can you please help me to modify this code?
function onEdit(e) {
const range = e.range;
const sheet = range.getSheet();
if (sheet.getSheetName() != "Sheet1" || range.rowStart == 1) return;
const col = range.columnStart - 1;
const [header, ...values] = sheet.getDataRange().getDisplayValues();
const value = values[range.rowStart - 2];
const v = [[`${value[0]} - ${value[1]}`, `${header[col]} - ${value[col]}`]];
e.source.getSheetByName("Sheet2").getRange("A2:B2").setValues(v);
}