Copies a range to another location or sheet.
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
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.
8 Snippets using this methods
- Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
- Basic CRM - Add a Powerful Script To Move Row Based on Status
- Automate Move Blank Rows
- Automatically Backup a Spreadsheet
- Automate Google Sheets With Zero Experience
- Automatic Calculations
- Automated Project Management in Google Sheets
- Americano Tournament Template With Four Automations
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.
More Apps Script
9 Better Sheets tutorials
Americano Tournament Template With Four Automations
Automated Project Management in Google Sheets
Automate Emails
Automate Google Sheets With Zero Experience
Automate Move Blank Rows
Automatically Backup a Spreadsheet
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
Basic CRM - Add a Powerful Script To Move Row Based on Status
Related blog posts
Written guides about SpreadsheetApp.copyTo().
How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
Read post →Automatic Weekly Backup of Google Sheets
How can we create backups of Google sheets every week or every day or every month?
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →