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

2 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 ...

Related blog posts

Written guides about SpreadsheetApp.getActive().

Browse the blog