I\'d like to be able to copy a colum (well 3) from a spreadsheet to another spreadsheet (google docs spreadsheets). I\'d also like there to be some sort of trigger that looks fo
I have found that it is easier to just copy the source_sheet to the target_spreadsheet, copy the necessary range using copyTo
then delete
the copied source_sheet.
// 1. Open source sheet
let spreadsheetFrom = SpreadsheetApp.openById(source_spreadsheet_id);
let sheetFrom = spreadsheetFrom.getSheetByName(source_sheet_name);
// 2. Copy source sheet to target spreadsheet
let spreadsheetTo = SpreadsheetApp.openById(target_spreadsheet_id);
let sheetCopy = sheetFrom.copyTo(spreadsheetTo);
// 3. Copy range from source_sheet's copy to target_sheet
let rangeFrom = sheetCopy.getRange('XX:YY');
let sheetTo = spreadsheetTo.getSheetByName(target_sheet_name);
let rangeTo = sheet.getRange('XX:YY');
rangeFrom.copyTo(rangeTo);
// 4. Delete source_sheet's copy
spreadsheetTo.deleteSheet(sheetCopy);