Finds a sheet tab by its name.
class SpreadsheetApp method .getSheetByName()
SpreadsheetApp is the Apps Script service.
.getSheetByName() is the method name you will see after a dot in your code.
What it does
Why it's used
- Jump straight to a tab like Archive or Settings by name.
- Safer than assuming the third tab is always the data sheet.
Common errors
- Forgetting parentheses on getSheetByName. Write SpreadsheetApp.getSheetByName(), not SpreadsheetApp.getSheetByName or getSheetByName by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').getSheetByName().
- Adding spaces where they do not belong. Write SpreadsheetApp.getSheetByName(), not SpreadsheetApp .getSheetByName(), SpreadsheetApp.getSheetByName (), or SpreadsheetApp . getSheetByName().
- Wrong capitalization. Use SpreadsheetApp and getSheetByName, not spreadsheetapp or getsheetbyname.
Snippets using this method
- Automatic Screenshots in Apps Script
- Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
- Automatically Uncheck A Daily Checklist
- Automatically Delete All Sheets If Not Listed Name
- Basic CRM - Add a Powerful Script To Move Row Based on Status
- Automatically Check Past Stages
- Automate Move Blank Rows
- Automatically Backup a Spreadsheet
- Automatically Clear Content | Refresh Reuse Recycle Templates
- Automate Form Response to Confirmation Email
- Automate Google Sheets With Zero Experience
- Automate Help Desk Ticket Closing
- Automatic Calculations
- Automated Project Management in Google Sheets
- Add NPS to Your Google Site
- Americano Tournament Template With Four Automations
- Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet
- Activate A Certain Sheet When Opening a Spreadsheet
- Access the Dictionary API to get Definitions for Words in Google Sheets
- 5 Ways To Use Google Sheets for Advanced Project Management
- 2 New Ways To Add Emoji Reactions
Explore
Related methods
-
.getSheets()
Returns every sheet tab in the spreadsheet.
-
.insertSheet()
Adds a new sheet tab to the spreadsheet.
-
.getActiveSheet()
Returns the sheet tab the user is viewing right now.
-
.deleteSheet()
Removes a sheet tab from the spreadsheet.
-
.getActiveSpreadsheet()
Returns the spreadsheet the user currently has open.
More Apps Script
Better Sheets tutorials
2 New Ways To Add Emoji Reactions
Access the Dictionary API to get Definitions for Words in Google Sheets
Activate A Certain Sheet When Opening a Spreadsheet
Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet
Add NPS to Your Google Site
Americano Tournament Template With Four Automations
Automated Project Management in Google Sheets
Automate Emails
Automate Form Response to Confirmation Email
Automate Google Sheets With Zero Experience
Automate Move Blank Rows
Automatically Backup a Spreadsheet
Automatically Check Past Stages
Automatically Clear Content | Refresh Reuse Recycle Templates
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
Automatically Delete All Sheets If Not Listed Name
Automatically Uncheck A Daily Checklist
Automatic Screenshots in Apps Script
Basic CRM - Add a Powerful Script To Move Row Based on Status
Related blog posts
Written guides about SpreadsheetApp.getSheetByName().
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 →How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
Read post →Getting Started Coding in Apps Script
What you need to know to access Apps Script inside Google Sheets. Code in Google Scripts. Automate business processes and more.
Read post →