class SpreadsheetApp method .getActive()

SpreadsheetApp is the Apps Script service.

.getActive() is the method name you will see after a dot in your code.

What it does

Returns the range the user currently has selected.

Why it's used

  • Let someone highlight cells and run a macro on just that selection.
  • Build formatters or validators that follow the user's cursor.

Common errors

  • Forgetting parentheses on getActive. Write SpreadsheetApp.getActive(), not SpreadsheetApp.getActive or getActive by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').getActive().
  • Adding spaces where they do not belong. Write SpreadsheetApp.getActive(), not SpreadsheetApp .getActive(), SpreadsheetApp.getActive (), or SpreadsheetApp . getActive().
  • Wrong capitalization. Use SpreadsheetApp and getActive, not spreadsheetapp or getactive.

Explore

Related methods

Better Sheets tutorials

Advanced Coding in Google Sheets for Programmers

Advanced Coding in Google Sheets for Programmers

Add a Custom Menu Create Native-like Functions Get URL and Sheet ID's vi...
Americano Tournament Template With Four Automations

Americano Tournament Template With Four Automations

Created a tournament template with 4 automations. So tabs can be copied ...
Better Sheets Videos Checklist

Better Sheets Videos Checklist

How to create a video checklist. Create a sheet with check boxes that yo...
Can I get alerted when a tab name is changed?

Can I get alerted when a tab name is changed?

Find out in this quick experiment if a tab name can be alerted to the ow...
Count Merged Rows

Count Merged Rows

Count the number of cells or rows in a merged cell. This is a quick litt...
Creating A Dark Mode Theme | Announcing Dark Habits

Creating A Dark Mode Theme | Announcing Dark Habits

Build a habit tracker in dark mode. Learn how to use emojis and checkbox...
Creating a Live Message in Google Sheets

Creating a Live Message in Google Sheets

Sit back and enjoy this comprehensive tutorial on how to create a live m...
Deep Inside Dark Habits Google Script

Deep Inside Dark Habits Google Script

Go inside this apps script and sheet. See how it's designed and created.
How To Download All Tabs as CSV in a Zip File

How To Download All Tabs as CSV in a Zip File

Download All Tabs as CSV in a Zip File, instead of downloading each one ...
How to Power Testimonials with Google Forms and Sheets

How to Power Testimonials with Google Forms and Sheets

I show you how I use a Google Form and a Google Sheet to power the testi...
How to Trigger Macros Daily

How to Trigger Macros Daily

Automate your apps script and macros you can record.
Introducing SheetFools

Introducing SheetFools

Free google sheets automations pranks you can use right now. Launching p...
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.
Scrape Google Maps

Scrape Google Maps

Scrape any query in Google Maps into your Google Sheets. Enter your API ...
Scrape Google Maps Added Phone and Reviews

Scrape Google Maps Added Phone and Reviews

Added two helper functions to get Phone numbers and reviews of the Googl...
Show Sheet Tabs Based on Edit

Show Sheet Tabs Based on Edit

Show a sheet or tab based on a code being entered in one sheet.
SubSpyHub Subreddit Scanner

SubSpyHub Subreddit Scanner

I built a subreddit search tool to keep track of subreddits with keyword...
Sync Many Tabs without ImportRange()

Sync Many Tabs without ImportRange()

Sync more than two tabs with Apps Script
Sync Tabs in Different Sections

Sync Tabs in Different Sections

How to sync different sections on different tabs. In this case we're tak...
Sync Two Tabs Without ImportRange()

Sync Two Tabs Without ImportRange()

Get this epic script that automatically edits two tabs and keeps them in...
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.getActive().

Browse the blog