I need my script to talk to the "current sheet" rather than sheet by name.

Code as is, selects cells from sheet 2019 but I want the script to copy the values from the current sheet, and paste into sheet Invoice.

function Inv1() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('InvBuilder'), true);
  spreadsheet.getRange('\'2019\'!B2:E28').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Invoice'), true);
  • In good faith, I hope you get it working, but I must say that SE is not a coding service or training forum. What have you tried? Have you looked into using your spreadsheet object's getActiveSheet() method? And why activate() and copyTo() rather than, from class Range, using getValue() and setValue() ? – Joel Reid Apr 11 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.