What replaces ThisWorkbook in Google Sheets?
In Excel VBA, ThisWorkbook refers to the file that hosts the code. In Apps Script bound to a spreadsheet, call SpreadsheetApp.getActiveSpreadsheet() for the same idea. Standalone scripts use openById or openByUrl with the spreadsheet ID from the URL.
When to use it
Use getActiveSpreadsheet when porting ThisWorkbook events or properties to a bound script.
When to skip it
Skip workbook object code when a single formula or IMPORTRANGE already reads the other file.
Better Sheets resources
Related Tutorials
Watch how ThisWorkbook works
MAKE Your Google Sheets Add-on WORK
The First Thing I Do When Starting a Google Sheet
Convert Google Sheets into a REST API
Get Every Editor on Every Google File I Own
Scrape Google Maps
Related blog posts
Guides that explain ThisWorkbook in more depth.
Extract URLs from Google Sheets
Extract url from hyperlink google sheets.Skip the Command K. This Google Sheet tutorial will make it easier for you to extract URLS from Google Sheets.
Read post →Learn to Code in Google Sheets, For Programmers | For Advanced Google Sheet Users
If you know how to code, you'll learn in this step-by-step tutorial how to code in Google Sheets.
Read post →Google Sheets Green Color Hex Code
Google Sheets Green Color Hex Code! Dive into #0F9D58, Google's vibrant shade of Green. The green color code you'll want to use in all your designs if you're google sheets adjacent.
Read post →Related terms
bound script
A bound script, also called a container-bound script, lives inside a specific spreadsheet file. You open it from Extensions > Apps Script and it travels with that workbook. getActiveSpreadsheet() works naturally because the script and sheet share one container. Most spreadsheet automations beginners build are bound scripts.
Read guide →Google Apps Script
Apps Script is Google's JavaScript platform for automating Sheets and other Workspace apps. From a spreadsheet you can open Extensions > Apps Script to write code that reads cells, sends email, builds menus, and runs on triggers. It goes beyond formulas when you need custom workflows tied to your file.
Read guide →spreadsheet
Spreadsheet is a core spreadsheet object in Google Sheets: the building blocks of every workbook. Sheets, tabs, rows, columns, cells, ranges, and values are the vocabulary every other feature builds on.
Read guide →getRange
getRange returns a Range object pointing at one or more cells on a sheet. You call it on a Sheet to read with getValue or getValues and write with setValue or setValues. Correct range targeting is the foundation of almost every Sheets script.
Read guide →Done reading about ThisWorkbook?
Membership unlocks 637+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.