I want to copy/paste the values of a specific column into the next column using a trigger at a certain time of the day. The script works when I run it manually, it runs as per 'last run' via trigger but it actually does not copy/paste the values via the trigger (only when I run it manually). Here is the script:

function eoddata() {
  var spreadsheet = SpreadsheetApp.getActive();
  var targetCell=spreadsheet.getRange('C1');
  spreadsheet.getRange('B1:B43').copyTo(targetCell, SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);

It used to run via trigger but I kept amending the sheet & script. How can I get this trigger to actually do copy/paste the values again pls?

  • The Range.copyTo() method accepts any range reference and only looks at the top-left cell of the target. Oct 14 '21 at 21:29

One potential issue is that the range references in the code do not specify a sheet name. When the function is run through an installable trigger, it will default to the first tab in the spreadsheet, rather than the tab the user at the keyboard has open at the time.

To make it work on another sheet, you need to specify a sheet name in the range references.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.