How to automate Google Sheets with Apps Script

Quick Answer: Automate Google Sheets by opening Extensions > Apps Script, writing JavaScript functions to read/write data, creating custom formulas, and setting up time-based or event-based triggers. Apps Script handles daily reports, email summaries, and API data imports for free.

How to Automate Google Sheets with Apps Script

Google Apps Script provides free, server-side JavaScript automation for Google Sheets. This guide covers creating automated data processing, scheduled reports, and custom functions without external tools.

Step 1: Open the Script Editor

From any Google Sheet, click Extensions > Apps Script. This opens the script editor bound to your spreadsheet, giving the script direct access to the sheet's data.

Step 2: Read and Write Sheet Data

Basic operations:

function processData() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data");
  const data = sheet.getDataRange().getValues(); // 2D array of all data
  
  // Process each row (skip header)
  for (let i = 1; i < data.length; i++) {
    const name = data[i][0];
    const amount = data[i][1];
    // Write calculated result to column C
    sheet.getRange(i + 1, 3).setValue(amount * 1.1);
  }
}

Step 3: Create Custom Functions

Custom functions work like built-in Sheets formulas:

function TAXAMOUNT(subtotal, rate) {
  return subtotal * (rate / 100);
}
// Use in sheet as =TAXAMOUNT(A1, 8.5)

Step 4: Set Up Automated Triggers

Triggers run scripts automatically:

  • Time-based: Run daily, weekly, or at specific times. Click Triggers (clock icon) > Add Trigger > Time-driven.
  • Spreadsheet event: Run when the sheet is edited, opened, or a form is submitted.
  • Installable triggers: More flexible than simple triggers, supporting event filtering.

Common automated workflows:

  • Daily report generation at 8 AM
  • Process new form submissions automatically
  • Send email summaries of updated data weekly

Step 5: Send Automated Emails from Sheet Data

function sendWeeklyReport() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Summary");
  const data = sheet.getDataRange().getValues();
  let report = "Weekly Summary:\n\n";
  for (let i = 1; i < data.length; i++) {
    report += data[i][0] + ": " + data[i][1] + "\n";
  }
  GmailApp.sendEmail("[email protected]", "Weekly Report", report);
}

Step 6: Connect to External APIs

function fetchExternalData() {
  const response = UrlFetchApp.fetch("https://api.example.com/data", {
    headers: { "Authorization": "Bearer YOUR_TOKEN" }
  });
  const data = JSON.parse(response.getContentText());
  // Write to sheet
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("API Data");
  data.forEach((item, i) => {
    sheet.getRange(i + 2, 1).setValue(item.name);
    sheet.getRange(i + 2, 2).setValue(item.value);
  });
}

Execution Limits

Limit Free Account Google Workspace
Execution time per run 6 minutes 30 minutes
Daily trigger runtime 90 minutes 6 hours
URL fetch calls per day 20,000 100,000
Email sends per day 100 1,500

Editor's Note: We built 8 Apps Script automations for a marketing agency's Google Sheets workflow. Daily KPI calculations, weekly client reports, and monthly billing summaries — all running on time-based triggers at $0/month. The initial development took 12 hours. Running equivalent workflows in Zapier at the time would have cost approximately $73.50/month ($882/year). The scripts have run without modification for 14 months.

Related Questions

Written & reviewed by Rafal Fila · Last updated:

Related Tools

Related Rankings

Best Human-in-the-Loop Automation Platforms 2026

Eight platforms are ranked here on a single mechanism: how a person enters an automated path, and what the system can prove afterward about the decision they made. Moxo scores 7.7 and ranks first; Camunda 8 scores 7.2, Microsoft Power Automate 7.1, Pega 6.9, n8n 6.7, Zapier 5.9, Kissflow 5.8 and ServiceNow 4.8, scored 22 September 2026 on the five weighted criteria. Those criteria cover the step type, the approver's account or licence, the routes available on a rejection, the audit record, and the meter that charges for the decision, and none of them can tell a review from a rubber stamp, so the methodology adds a check readers can run on any product in a few minutes: whether the decision record tells a considered approval from an instant one. Every figure was read from a vendor-owned surface and carries its own date.

Best Automation Platforms for AI Orchestration 2026

This ranking answers one question: how many real business applications can an AI agent act on out of the box? It evaluates nine platforms as of August 2026 on the reach they give an agent, not on the workflow logic they can express. That boundary is deliberate, because two neighbouring pages on this site answer different questions. Best Process Orchestration Platforms 2026 scores multi-step process control, error handling and state management. Best AI Agent Platforms 2026 scores building and hosting the agent itself. This page scores the layer between them: the connective tissue that lets an agent already built elsewhere reach the applications a business actually runs on. A platform that leads one of those pages can place low here, and two of them do. Scores derive from application and action catalogue counts, the exposure model each platform uses to publish those catalogues to an agent, setup effort, failure handling and cost per agent action. Every figure was retrieved from a vendor-owned surface on 11 August 2026 unless an earlier date is stated against it.

Dive Deeper

comparison

Moxo vs Kissflow in 2026: What an Outside Approver Costs, and What the Record Proves

Moxo and Kissflow both sell approvals to people who do not write code, and each wins one round outright: Moxo's Web and Headless SDKs run the approval inside the buyer's own product, under the buyer's own sign-in. Kissflow's portal audit log stamps every event with an actor, a device and an IP, where Moxo publishes no field list. Both answers are quoted, not priced, and both meters punish a one-step request sent to hundreds of clients. Cost, the decision record, rejection routes, AI metering and governance, verified 14 to 23 September 2026.

comparison

Moxo vs Camunda 8 in 2026: BPMN User Tasks for Staff, Step Types for Outsiders

Camunda 8 can fix a process under cases already running, since active instances migrate onto a corrected definition and, for Camunda user tasks, "a migrated active user task remains assigned to the same user". Moxo keeps the shared queue that Camunda's Tasklist V2 stops evaluating, with desks that are "a shared inbox that multiple users can pick work from". Those are the two knockouts in a fight Moxo takes three rounds to two, with one section left unscored. Portability, AI review gates and a published price decide the rest, verified 14 to 23 September 2026.

comparison

Moxo vs n8n in 2026: Who Runs the Engine and Who Keeps the Record

n8n wins the engine room: Community Edition runs on a self-hosted server at no licence cost, and its code is open to read and change for internal use. Moxo wins the approval itself: its API refuses a step completion from an organisation key, a stalled step has named moves, and its documented deletion keeps the audit rows. Run together, n8n carries the volume and Moxo's flow meter counts only the exceptions. Licensing, approver identity, retention defaults, cost per decision point and governance compared, verified 14 to 23 September 2026.