By Raj
Part of our Google Sheets Automation Expert guides. Need this built for your team? Hire a Google Apps Script developer.
Estimated reading time: 10 minutes
10 Google Sheets Automation Examples (With Scripts)
These ten Google Sheets automation examples mirror what operations teams request first: alerts, deduplication, scheduled PDFs, and CRM sync stubs. Each pattern uses batch I/O and installable triggers where external APIs are involved.
Examples assume a Data tab with headers in row 1 and no merged cells in the data rectangle. Copy functions into the script editor bound to your workbook, authorize once, then add triggers from the Triggers UI.
For macro limitations, see /blog/google-sheets-macro-vs-apps-script. For Slack-specific alerts, see /blog/google-sheets-send-slack-notification.
Threshold email alerts
Scan the Quantity column each hour; when any row drops below reorder point, append to a digest array and send one MailApp.sendEmail instead of one mail per SKU.
Store last_alerted timestamps in Script Properties to avoid duplicate emails if the sheet still shows low stock next run.
Deduplicate by composite key
Load keys with getValues(), track seen keys in an object, and delete rows from bottom to top so indices stay valid.
Log how many duplicates were removed to a RunLog sheet for auditors.
Scheduled PDF reports
Export a dashboard tab with getAs('application/pdf') and email via GmailApp.sendEmail with attachment blobs.
Name files with timezone-aware timestamps using Session.getScriptTimeZone().
Append-only import queue
External CSV drops land in Drive; a time-driven script parses and appends only new keys—pattern detailed in /blog/google-sheets-import-csv-automatically.
Use a Staging tab for validation before promoting rows to Production.
Example code
function alertLowStock() {
const sh = SpreadsheetApp.getActive().getSheetByName('Inventory');
const rows = sh.getRange(2, 1, sh.getLastRow() - 1, 4).getValues();
const lows = rows.filter(function (r) { return r[3] < r[2]; }).map(function (r) { return r[0] + ': ' + r[3]; });
if (!lows.length) return;
MailApp.sendEmail(Session.getActiveUser().getEmail(), 'Low stock', lows.join('\n'));
}| Approach | Best for | Tradeoff |
|---|---|---|
| Apps Script native | Google Workspace-centric workflows | 6-min limit, quotas |
| Zapier / Make | No-code, many connectors | Per-task cost, vendor lock-in |
| Python + Cloud | Heavy data / ML | Hosting cost, separate auth |
| Google Sheets automation expert | Production custom logic | Build cost, you own code |
FAQ
Which example runs on edit?
Validation highlights and Slack row notifications typically use installable onEdit triggers. Heavy imports should be time-driven, not on every keystroke.
Can I run all ten in one project?
Yes, but separate triggers and namespace functions clearly. Shared CONFIG sheet reduces hard-coded column indexes.
Do examples work on Excel-exported sheets?
Clean dates and numbers first—Excel serials may import as strings. Use setNumberFormat after verifying typeof row[2] === 'number'.
How do I test without spamming email?
Point MailApp recipients to your own address via a TEST_MODE flag in Script Properties during UAT.
Where are more copy-paste scripts?
Browse /free-scripts for additional snippets or hire /services/google-sheets-automation-expert for production hardening.
Need this done for you? I handle this as part of my consulting work — fixed-price quote within 24 hours.
Book a call with Raj →Get the full 10 Google Sheets Automation Examples (With Scripts) script template
I'll email you a production-ready, commented version you can deploy in 10 minutes.
Continue reading
Google Sheets Automation
Google Sheets CRM Automation: Triggers, Pipelines, and Follow-Ups
Google Sheets Automation
Google Sheets Dashboard Automation with Apps Script
Google Sheets Automation
Auto-Generate Reports from Google Sheets with Apps Script
From another topic
How to Automate Google Sheets with Apps Script (Beginner Guide) →Need help with this? I handle this as part of my Google Sheets Automation Expert service.
CRM, dashboards, invoices, inventory, and report automation in Sheets.
See how it works →