Step-by-Step Instructions to add Apps Script to Google Sheet
How to Add This Apps Script to a Google Sheet
Before you begin: These instructions walk you through adding a script that runs directly from the Apps Script code editor. Once the script finishes running, you’ll switch back to your Google Sheet to see the results — the script creates a new tab named Sheet Size Audit.
Step 1 — Open Your Google Sheet
Open the Google Sheet where you want to run the script.
Step 2 — Open the Apps Script Editor
Go to Extensions > Apps Script in the menu bar. (Be careful — you want Apps Script, not AppSheet, which appears just below it.)
A new browser tab will open with the Apps Script editor.
Step 3 — Check for Existing Scripts
Before doing anything else, look at the left sidebar under Files. You’ll see at least one file listed — usually named Code.gs.
If you see only Code.gs with the default placeholder code (it typically looks like an empty function myFunction() {}), you’re clear to proceed.
If you see multiple files, or Code.gs already contains real code, stop. This sheet already has an Apps Script attached to it. Do not delete or overwrite existing code — you could break something that’s already working. Instead, add a new script file: click the + icon next to Files in the left sidebar and choose Script. Give it a descriptive name (e.g., auditSheetSize). Your new code will live there without disturbing anything else.
Step 4 — Name Your Project
Near the top of the page, you’ll see the project name — it likely says Untitled project. Click on it and rename it to something meaningful, like auditSheetSize. This just helps you recognize the project later; it doesn’t affect how the script runs.
Step 5 — Clear the Placeholder Code
Click on Code.gs (or your newly created script file) in the left sidebar. You’ll see a small block of placeholder code in the editor — something like:
function myFunction() {
}
Select all of it and delete it. The editor should now be completely empty.
Step 6 — Paste the Script Code
Paste the Apps Script code from this post into the now-empty editor.
Step 7 — Save the Script
Click the Save button (the floppy disk icon in the toolbar), or press ⌘S on macOS / Ctrl+S on Windows. You should see the save indicator confirm the file was saved.
Step 8 — Confirm the Function Name
In the toolbar near the top of the editor, there’s a dropdown showing the function to be run. It should already display auditSheetSize — that’s the only function in this script, so no selection is needed.
Step 9 — Authorize the Script (First Run Only)
Click the Run button.
The first time you run any Apps Script, Google will ask you to authorize it. This is normal and expected. Work through the steps as follows:
-
Click Review permissions
-
Choose your Google account
-
You may see a warning that says “Google hasn’t verified this app.” This is standard for personal scripts. Click Advanced, then Go to [project name] (unsafe) to continue.
-
Click Allow
This authorization happens only once. Future runs won’t ask again.
Step 10 — View the Results
Watch the Execution log panel at the bottom of the editor for progress updates. When it confirms the script has completed, switch back to your Google Sheet tab in the browser. You’ll find a new tab at the bottom of the sheet named Sheet Size Audit — that’s where your results are.
Depending on the size of your sheet (number of tabs, volume of data), execution may take anywhere from a few seconds to a minute or more. Larger files take longer.
Troubleshooting tip: If you see an error in the execution log, the most common causes are a missed step during authorization or a copy/paste error in the code. Re-check that the code was pasted completely and try again.