class SpreadsheetApp method .copyTo()

SpreadsheetApp is the Apps Script service.

.copyTo() is the method name you will see after a dot in your code.

What it does

Copies a range to another location or sheet.

Why it's used

  • Duplicate a template block to a new sheet or file.
  • Back up a range before overwriting it with fresh data.

Common errors

  • Forgetting parentheses on copyTo. Write SpreadsheetApp.copyTo(), not SpreadsheetApp.copyTo or copyTo by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').copyTo().
  • Adding spaces where they do not belong. Write SpreadsheetApp.copyTo(), not SpreadsheetApp .copyTo(), SpreadsheetApp.copyTo (), or SpreadsheetApp . copyTo().
  • Wrong capitalization. Use SpreadsheetApp and copyTo, not spreadsheetapp or copyto.

Explore

Related methods

  • .activate()

    Makes a sheet or range the active selection.

  • .getRange()

    Returns a range of cells by A1 notation or row and column numbers.

  • .setValues()

    Writes a 2D array of values into a range of cells.

  • .offset()

    Returns a range shifted by a number of rows and columns.

  • .insertSheet()

    Adds a new sheet tab to the spreadsheet.

9 Better Sheets tutorials

Americano Tournament Template With Four Automations

Americano Tournament Template With Four Automations

Created a tournament template with 4 automations. So tabs can be copied ...
Automated Project Management in Google Sheets

Automated Project Management in Google Sheets

Create automatic notifications when a project is assigned, a project nee...
Automate Emails

Automate Emails

Set up automated email notifications based on Google Sheets data. Super ...
Automate Google Sheets With Zero Experience

Automate Google Sheets With Zero Experience

By the end of this video you should be knowledgeable about how to automa...
Automate Move Blank Rows

Automate Move Blank Rows

Automate the apps script we just created that moves blank rows from one ...
Automatically Backup a Spreadsheet

Automatically Backup a Spreadsheet

Make a copy and rename to BACKUP plus the Date of the backup. Execute th...
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas

Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas

Automatically copy a spreadsheet tab to a whole new spreadsheet file, ge...
Automatic Calculations

Automatic Calculations

Create custom scripts to make your spreadsheets more like tools.
Basic CRM - Add a Powerful Script To Move Row Based on Status

Basic CRM - Add a Powerful Script To Move Row Based on Status

we're going to be adding a very powerful script to our CRMs or any datab...

Related blog posts

Written guides about SpreadsheetApp.copyTo().

Browse the blog