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
- Ultimate Prompt Writer and Prompt Rater
- Uncheck Every Checkbox in Google Sheets
- Ultimate Prompt Writer and Prompt Rater
- Upgrade Google Sheets OpenAI Prompt to GPT 4
- Visicalc 2023 Design Walkthrough
- Visicalc 2023 Quick Walkthrough
- Send a Button from Google Sheets in an Email
- Simple Inventory Management Automations
- Sync Tabs in Different Sections
- Sync Many Tabs without ImportRange()
- Timestamp When Done (With Code)
- Spreadsheet Automation for Beginners
- Shaman: AI Blog Writer
- Spreadsheet Automation for Beginners
- Shaman: AI Blog Writer
- Shaman: AI Blog Writer
- SOLUTIONS! Solve The Errors, Learn For Loop
- Show Sheet Tabs Based on Edit
- Tag Emails From A List of Members in Google Sheets
- Twitter App Clone in a Google Sheet
- Sync Two Tabs Without ImportRange()
- Send a Daily Email with Inspiring Quote - A Little Pick Me Up
- Track Every Edit (Almost)
- Sheet Stories / Video Notes + Clear 24 Hour Old Videos
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
Better Email Form on Google Sites
Bjarne Asks: Can I show the Last Time of the Last Edit in a sheet?
Breaking Through Errors In Apps Script
Build a Book Recommender with AI in Google Sheets
Build a Case Converter From Scratch
Build a License Key Generator and API in 20 Minutes
Build a Startup Pitch Generator in 20 minutes
Building an AI Prompts Playground
Build Your Own AI Writer in Google Sheets
Build Your Own Free Domain Availability Checker
Built a Cookie Clicker Clone in Google Sheets
Can I Automatically Rename a Sheet based on a Date?
Capture Emails from Website Form to a Google Sheet (Without Zapier)
ChatGPT Clone in Google Sheets Part 1
ChatGPT Clone in Google Sheets Part 2
Convert Google Sheets into a REST API
Create a ChatGPT Cheat Sheet Spreadsheet
Create an Automated Task List
Create a new Spreadsheet from just a Name in a Sheet.
Create a PR Agency From Scratch
Create a Radio Button From Checkboxes Using Google Apps Script
Create a Stop Watch in a Google Sheet
Create a Timer with Apps Script
Create a Tracking Number Fetcher with Google Sheets and Google Sites
Create a Vote Button from Google Sites to Google Sheets
Create a Waterfall of AI Prompts and Responses
Create Navigation Like A Book or Presentation
Create New Worksheet When Google Form Submitted
Create Your Own NIGHT Mode (like PRIDE)
Creating A Dark Mode Theme | Announcing Dark Habits
CRM Automations
Curate Google Sheets Easily - Automatic Bookmarklet Maker
Daily Writer's Word Count Tracker
Deep Inside Dark Habits Google Script
Don't Delete My Formulas
Dylan Asks: How to Automatically Delete Rows If Cell Contains Value
Email Certain Department Based on Google Form Entries
Email Myself a Daily Random Motivational Quote
Email Yourself a Cell from a Google Sheet, Every Day
Embed a Headline in a Website from Google Sheets
Embed a Number in a Website from a Google Sheet
Embed Email Form and Name Form into Website to Google Sheets
Embed Quote and Author to Daily Quote Website
Every Google Drive File Created in Last 24 Hours
Every Locale Listed in Google Sheets and a Tool to Save Your Sanity
Expense Tracker Template with Data Entry Form Inside Sheets
Fast FAQS
Form Automations: Close Multiple Forms When Over Limit
Get Every Editor on Every Google File I Own
Getting Started Coding in Apps Script
Google Maps Scraper for Outreach
Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.
Hold a Giveaway Raffle in a Google Sheet
How do I reference a different spreadsheet in Apps Script?
How To Change Date Format Automatically
How to Copy To New Tab When Checked
How to Create AI Images From Google Sheets
How To Duplicate a Tab and Move it to the End in Google Sheets
How To Format Sheets for Notes
How to Merge Cells in Google Sheets
How To Send Two Emails in Same Trigger
How to Turn Background Color to Text
How to Validate Email Addresses
I Created an Automatic Emailer
Idea Graveyard - Create a Decaying Checklist
Introducing SheetFools
Iterate Numbers with a Simple Apps Script
Laziest Checklist Ever
Learn to Code in Google Sheets, For Programmers
LinkTree in a Google Sheet
Make AI-generated Poems Based on Name
Make a Tour of Your Sheet
MicroManager: Hourly Email Reminders
Move Blank Rows
Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script
Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5
Onboarding Scheduler
One Million Checkboxes
One Weird Google Sheet Formula for Bulk Publishing With AI
OpenAI API Prompt with Array of Cells
Password Protecting Data In a Google Sheet
Password Protecting Data In a Google Sheet Part 2 The Basics
Prompt Parade
Quickly Build a Daily Random Motivational Quote Website
Quickstart Tutorial OpenAI API in Google Sheets
Richard Asks: Copy Template Tab and Rename to Date Every Week
Run 100 ChatGPTs at One Time
Saving OpenAI API Calls inside of Google Sheets
Scrape Google Maps
Scrape Google Maps Added Phone and Reviews
Send a Button from Google Sheets in an Email
Send a Daily Email with Inspiring Quote - A Little Pick Me Up
Send Daily Email Updates
Shaman: AI Blog Writer
Show Sheet Tabs Based on Edit
Simple Inventory Management Automations
SOLUTIONS! Solve The Errors, Learn For Loop
Solve The Errors, Learn For Loop
Sync Tabs in Different Sections
Sync Two Tabs Without ImportRange()
Tag Emails From A List of Members in Google Sheets
Timestamp When Done (With Code)
Track Every Edit (Almost)
Ultimate Prompt Writer and Prompt Rater
Uncheck Every Checkbox in Google Sheets
Visicalc 2023 Design Walkthrough
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 →