Guides.
Every how-to and example script we've written, in one list. Each one starts from a real problem someone hit in Google Apps Script and ends with code you can paste. No hello-world, no filler.
How-tos
- Sheets · Gmail
Send bulk emails from a spreadsheet in Google Sheets
I have a column of email addresses. I want to email each one without copying them into BCC.
- Forms · Sheets · Slack
Log form submissions to a spreadsheet in Google Sheets
Every time someone submits my form, I want a row in a sheet and a Slack ping if it's urgent.
- Gmail
Auto-archive old emails on a schedule with Apps Script
I want my inbox to stop growing. Anything older than a month should fall off the front page automatically.
- Sheets
Auto-fill the date when a row is edited in Google Sheets
When I add a new entry I want the timestamp to fill itself. I'm tired of typing =NOW() and pasting as value.
- Sheets · Gmail · Drive
Export a Google Sheet to PDF and email it on a schedule
I want my Friday report mailed out without me opening a sheet. PDF attachment, three recipients, done.
- Calendar · Sheets
Sync Google Calendar events into a spreadsheet for reporting
I want my next month of meetings as rows in a sheet so I can pivot, sort, and report on them.
- Sheets · Slack
Slack a notification when a cell flips to "ready" in Google Sheets
When my team marks an item ready in the tracker, I want Slack to ping us — not me checking the sheet every hour.
- Sheets · Apps Script
Convert a column number to a letter in Google Sheets
I have a column number and I need its A1 letter so I can build a range string like 'AB1:AB100'.
- Sheets · Apps Script
Find the last row with data in a column in Google Sheets
I need the last row that has data in column C specifically, but getLastRow() keeps returning the bottom of the whole sheet.
- Sheets · Apps Script
Convert a Unix timestamp to a date in Google Sheets
I have a column of Unix timestamps from an API and I need them as readable dates in my sheet's timezone.
- Sheets · Apps Script
Copy a row to another sheet in Google Sheets
I want to move or duplicate a row from one tab to another — triggered by a status change or a button — without dragging in formatting I didn't ask for.
- Sheets · Apps Script
Get unique values from a column in Google Sheets
I need to pull every distinct value out of a column in Google Sheets without duplicates, and UNIQUE() alone is not cutting it because I need the result in a script.
- Sheets · Apps Script
Split a full name into first and last columns in Google Sheets
I have a column of full names and need to split them into separate first and last name columns without mangling names like "Mary Jo Smith" or "Jean-Pierre Dupont."
- Sheets · Apps Script
Sum a column by a matching value in Google Sheets
I want to total up numbers in one column only where the adjacent label column matches a specific value, and I want to do it without a formula that breaks when my data grows.
- Sheets · Apps Script
Freeze the header row in Google Sheets
I want to freeze the first row of my spreadsheet so the column headers stay visible when I scroll down, and ideally make it obvious that row is the header.
- Sheets · Apps Script
Highlight duplicate values in Google Sheets
I want to automatically highlight every cell that contains a duplicate value in a column or range, without the script timing out on a sheet with thousands of rows.
- Sheets · Apps Script
Clear a range but keep formatting in Google Sheets
I need to reset the data in a range every week but I keep losing the formatting I spent time setting up.
- Sheets · Apps Script
Delete empty rows in Google Sheets
I have a spreadsheet full of empty rows scattered through the data and I want to remove all of them at once without clicking through them manually.
- Sheets · Apps Script
Move a row to another sheet on edit in Google Sheets
I want to automatically move a row to another sheet the moment I mark it Done, without manually cutting and pasting or running a script by hand.
- Sheets · Apps Script
Insert a timestamp when a row is added in Google Sheets
I want to record exactly when a row was first created in my spreadsheet, not when it was last touched.
- Sheets · Apps Script
Remove duplicate rows in Google Sheets
I have a Google Sheet with duplicate rows and I want to remove them programmatically, either on demand or on a schedule, without destroying the rest of my data.
- Sheets · Apps Script
Create a named range in Google Sheets
I keep hardcoding A1 addresses in my Apps Script and they break silently when someone inserts a row.
- Drive · Apps Script
Share a Drive file with a specific user in Google Drive
I want to programmatically share a Google Drive file with a specific person's email address from Apps Script, and I'm not sure whether to use addEditor, setSharing, or something else entirely.
- Drive · Apps Script
Move a file to another folder in Google Drive
I want to write an Apps Script that moves a Google Drive file into a different folder without duplicating it or leaving it in the original location.
- Sheets · Apps Script
Set a dropdown list from a range in Google Sheets
I want to create a dropdown validation rule in Google Sheets via Apps Script that reads its options from a live range, so the list updates automatically when I add new items.
- Sheets · Apps Script
Alternate row colors with a script in Google Sheets
I want to stripe alternating row colors in my Google Sheet without manually painting every other row, and without the banding API re-flowing my colors whenever I insert or delete rows.
- Sheets · Apps Script
Sort a sheet by multiple columns in Google Sheets
I need to sort a Google Sheet by more than one column from a script, and I keep getting the wrong rows sorted or the wrong order.
- Sheets · Apps Script
Append a row to the top of a sheet in Google Sheets
I want to add a row of data to the top of my sheet so the most recent entry appears first, but appendRow keeps writing to the bottom.
- Sheets · Apps Script
Find and replace across a sheet in Google Sheets
I need to programmatically find and replace a string across my whole Google Sheet without manually opening the Find & Replace dialog every time.
- Sheets · Apps Script
Count cells by background color in Google Sheets
I need to count how many cells in a column share the same background color, and the built-in COUNTIF has no color argument.
- Docs · Apps Script
Find and replace text in a Google Doc in Google Docs
I want to programmatically find and replace text in a Google Doc using Apps Script, but my replacements are matching the wrong characters because I forgot replaceText takes a regex.
- Sheets · Apps Script
Protect a range from editing in Google Sheets
I want to lock a specific range in my Google Sheet so collaborators can't accidentally overwrite formulas or reference data, and I want to do it programmatically so I don't have to repeat the UI clicks every time the sheet is re-created.
- Sheets · Apps Script
Copy values only without formulas in Google Sheets
I want to copy a range in Google Sheets and have the destination contain the computed results, not the original formulas.
- Docs · Drive · Apps Script
Generate a doc from a template with placeholders in Google Docs
I want to fill a Google Doc template with data from a script without destroying the original template each time I run it.
- Sheets · Apps Script
Add a checkbox to a cell in Google Sheets
I want to programmatically insert a checkbox into a Sheets cell and react to it being checked or unchecked, without clicking through the Insert menu by hand.
- Gmail · Apps Script
Send an email with an attachment in Gmail
I want to send an email from Apps Script that includes a file from Google Drive as an attachment, but the attachment never shows up in the message.
- Forms · Gmail · Apps Script
Email a summary when a form is submitted in Google Forms
I want to receive an email with the submitted answers every time someone fills out my Google Form, without checking the responses tab manually.
- Sheets · Calendar · Apps Script
Create a calendar event from a spreadsheet row in Google Calendar
I want to turn rows in a Google Sheet into Calendar events without ending up with duplicate events every time the script runs.
- Sheets · Apps Script
Convert text to uppercase in a range in Google Sheets
I want to uppercase all the text in a column or selection without retyping or adding a helper column full of UPPER() formulas.
- Gmail · Apps Script
Label emails matching a search query in Gmail
I want to bulk-label a set of emails matching a Gmail search string without clicking through hundreds of threads by hand.
- Calendar · Apps Script
Add a guest to a calendar event in Google Calendar
I need to programmatically add one or more guests to an existing Google Calendar event without manually editing each event in the UI.
- Gmail · Apps Script
Count unread emails by label in Gmail
I want to read the unread count for a specific Gmail label in Apps Script without looping through every thread.
- Drive · Apps Script
List all files in a folder in Google Drive
I want to write an Apps Script that lists every file inside a Drive folder, but I'm getting only some of the files back and can't figure out why subfolders are missing.
- Drive · Apps Script
Create a Drive folder only if it doesn't exist in Google Drive
I want to create a Google Drive folder in Apps Script but only if it doesn't already exist, so repeated runs don't pile up duplicates.
- Gmail · Apps Script
Create a draft reply in Gmail
I want to programmatically draft a reply to an email and have it appear in the same thread, not as a new conversation.
- Gmail · Drive · Apps Script
Save Gmail attachments to a Drive folder in Gmail
I need to automatically pull file attachments out of Gmail and store them in a Drive folder without manually saving each one.
- Sheets · Apps Script
Generate a sequential ID for new rows in Google Sheets
I want every new row in my sheet to get a unique sequential ID, but concurrent form submissions keep assigning the same number to two rows at once.
- Sheets · Apps Script
Transpose a range with a script in Google Sheets
I want to rotate rows into columns (or vice versa) programmatically so I can automate a report layout without doing it by hand every time.
- Gmail · Apps Script
Forward matching emails automatically in Gmail
I want emails matching a specific sender or keyword to be forwarded to another address automatically, without babysitting my inbox.
- Docs · Apps Script
Append a table to a Google Doc in Google Docs
I want to programmatically insert a table into a Google Doc using Apps Script without manually formatting cells one by one.
- Calendar · Apps Script
List today's calendar events in Google Calendar
I want to write an Apps Script that logs or processes every calendar event happening today, and I keep getting incomplete results.
- Forms · Apps Script
Clear all responses from a form in Google Forms
I need to wipe all collected responses from a Google Form before re-running a survey or event registration, and I want it done in one script rather than clicking through the UI every time.
- Sheets · Apps Script
Hide rows based on a cell value in Google Sheets
I need a script that hides every row where a specific column contains a given value, without manually filtering or hitting the 30-second execution limit on big sheets.
- Gmail · Apps Script
Mark emails as read by search in Gmail
I want to run a Gmail search and mark all matching threads as read without burning through my script quota by looping over individual messages.
- Forms · Apps Script
Build a pre-filled form URL in Google Forms
I want to generate a Google Form link that already has certain fields filled in, so the person who opens it only needs to review and submit.