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.

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...
ChatGPT Clone in Google Sheets Part 2

ChatGPT Clone in Google Sheets Part 2

We fix the problem of OpenAI's API not remembering our last questions. A...
Copy That, From One Sheet to Another - Learn to Code in Google Sheets Part 4

Copy That, From One Sheet to Another - Learn to Code in Google Sheets Part 4

Learn to code in sheets. Automate Your Daily Sales Report with Google Sh...
CRM Automations

CRM Automations

Simple automations you can add you to your CRM to keep it clean and look...
Different Kinds of Automation

Different Kinds of Automation

A brief description of types of automation. I go way more in depth in “M...
How To Duplicate a Tab and Move it to the End in Google Sheets

How To Duplicate a Tab and Move it to the End in Google Sheets

Learn how to automate creating a template and moving the tab to the far ...
How to Trigger Macros Daily

How to Trigger Macros Daily

Automate your apps script and macros you can record.
Learn to Code in Google Sheets, For Programmers

Learn to Code in Google Sheets, For Programmers

Google Sheets uses a scripting language called Google Apps Script, which...
Move Blank Rows

Move Blank Rows

Apps Script function to move all blank rows if a certain column is not f...
Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

This is one of the most popular asked first "automations". How to move a...
Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5

Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5

Now that we have a script that we wanna run every day, how do we run thi...
Reformat Pasted Cells Automatically

Reformat Pasted Cells Automatically

Create uniform formatting even if you're copy and pasting data that is d...
Richard Asks: Copy Template Tab and Rename to Date Every Week

Richard Asks: Copy Template Tab and Rename to Date Every Week

Member Richard asks this question. Answer: use Google Script and a Trigger.
Twitter App Clone in a Google Sheet

Twitter App Clone in a Google Sheet

I built a twitter clone in Google Sheets
Ultimate Prompt Writer and Prompt Rater

Ultimate Prompt Writer and Prompt Rater

Create a chat interface inside of Google Sheets using GPT-4. Insert rows...
Visicalc 2023 Design Walkthrough

Visicalc 2023 Design Walkthrough

Design walkthrough of VisiCalc 2023. Watch this if you'd like to see the...
Visicalc 2023 Quick Walkthrough

Visicalc 2023 Quick Walkthrough

This is a fun template I created for April 1st. Take a quick walk throug...

Related blog posts

Written guides about SpreadsheetApp.copyTo().

Browse the blog