Returns the range the user currently has selected.
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
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.
2 Snippets using this methods
Explore
Related methods
-
.getActiveSpreadsheet()
Returns the spreadsheet the user currently has open.
-
.activate()
Makes a sheet or range the active selection.
-
.getActiveSheet()
Returns the sheet tab the user is viewing right now.
-
.getRange()
Returns a range of cells by A1 notation or row and column numbers.
-
.getDataRange()
Returns the smallest range that contains all data on the sheet.
More Apps Script
2 Better Sheets tutorials
Advanced Coding in Google Sheets for Programmers
Americano Tournament Template With Four Automations
Related blog posts
Written guides about SpreadsheetApp.getActive().
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 →