Returns the spreadsheet the user currently has open.
class SpreadsheetApp method .getActiveSpreadsheet()
SpreadsheetApp is the Apps Script service.
.getActiveSpreadsheet() is the method name you will see after a dot in your code.
What it does
Why it's used
- Nearly every bound script starts here so you can read or write the sheet the user has open.
- Custom menus and sidebar tools need this before they can touch any data.
Common errors
- Forgetting parentheses on getActiveSpreadsheet. Write SpreadsheetApp.getActiveSpreadsheet(), not SpreadsheetApp.getActiveSpreadsheet or getActiveSpreadsheet by itself.
- Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').getActiveSpreadsheet().
- Adding spaces where they do not belong. Write SpreadsheetApp.getActiveSpreadsheet(), not SpreadsheetApp .getActiveSpreadsheet(), SpreadsheetApp.getActiveSpreadsheet (), or SpreadsheetApp . getActiveSpreadsheet().
- Wrong capitalization. Use SpreadsheetApp and getActiveSpreadsheet, not spreadsheetapp or getactivespreadsheet.
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
- Send Better Email When Google Form Filled Out
- Sync Tabs in Different Sections
- Sync Many Tabs without ImportRange()
- Timestamp When Done (With Code)
- Self Destructing Google Sheet
- 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
Explore
Related methods
-
.getActive()
Returns the range the user currently has selected.
-
.getActiveSheet()
Returns the sheet tab the user is viewing right now.
-
.activate()
Makes a sheet or range the active selection.
-
.openByUrl()
Opens an existing spreadsheet from its full URL.
-
.openById()
Opens an existing spreadsheet using its Drive file ID.
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
Advanced Coding in Google Sheets for Programmers
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
Automatic Weekly Backup of Google Sheets
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
Brighten Up Your Checklist Automatically
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?
Can I get alerted when a tab name is changed?
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
Close Form After Certain Number of Responses
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 Custom URL Link for Your Spreadsheet
CRM Automations
Curate Google Sheets Easily - Automatic Bookmarklet Maker
Daily Writer's Word Count Tracker
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
From Sheet to Script And Back Again - Learn to Code In Google Sheets Part 3
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 a Google Form Automatically
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 Move Tab To End Easily with Apps Script
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
Self Destructing Google Sheet
Send a Button from Google Sheets in an Email
Send a Daily Email with Inspiring Quote - A Little Pick Me Up
Send Better Email When Google Form Filled Out
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.getActiveSpreadsheet().
How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
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 →Spreadsheets Explained! 5 Levels of Difficulty: From Basic Text Input to Google Apps Script
Five increasingly difficult ways of explaining spreadsheets in Google Sheets: The basics of Google Sheets text Menu items in Google Sheets Math inside Google Sheets Using Formulas in Google Sheets Apps Script in Google Sheets
Read post →