Post

Automate Google Sheets with Google Apps Script: A Step-by-Step Beginner's Guide

Automate Google Sheets with Google Apps Script: A Step-by-Step Beginner's Guide

Google Apps Script is a free, cloud-based JavaScript platform that lets you add super-powers to Google Workspace. In this tutorial, you’ll learn how to automate Google Sheets in just a few minutes—no prior coding experience required.

Why Automate Google Sheets?

  • Save time by turning manual tasks into one-click actions.
  • Reduce errors caused by copy-and-paste or formula mishaps.
  • Stay organised with scheduled triggers that run while you sleep.

SEO tip: People often search for “how to automate Google Sheets” or “beginner Google Apps Script.” We use these phrases naturally throughout the article to help readers (and search engines) find us.


Prerequisites

  1. A Google account (Gmail works fine).
  2. A Google Sheet with some sample data.
  3. Basic familiarity with spreadsheets—no coding knowledge needed!

Step 1: Open the Apps Script Editor

  1. Open your Google Sheet.
  2. Click Extensions → Apps Script.
  3. Delete any code inside the editor so you start fresh.

You’re now in the Apps Script IDE, ready to code.

Step 2: Write Your First Script

Paste the following snippet into the editor. It takes the values in column A, adds today’s date to column B, and sets the status in column C to “Processed.”

1
2
3
4
5
6
7
8
9
10
11
12
function addTimestampAndStatus() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const dataRange = sheet.getRange("A2:A" + sheet.getLastRow());
  const data = dataRange.getValues();

  data.forEach((row, i) => {
    if (row[0] !== "") { // skip empty rows
      sheet.getRange(i + 2, 2).setValue(new Date());        // Column B
      sheet.getRange(i + 2, 3).setValue("Processed");      // Column C
    }
  });
}

What the Code Does

  • Gets the active sheet so you don’t need to hard-code the name.
  • Loops through every non-empty row in column A.
  • Adds a timestamp in column B.
  • Marks the status as “Processed” in column C.

Step 3: Run the Script Manually

  1. Click the save icon (or press Ctrl + S).
  2. Name your project (e.g., Sheet Automation).
  3. Click the Run ▶️ button.
  4. Authorise the script (first-time only).

Check your sheet—column B now shows today’s date, and column C says “Processed.” 🎉

Step 4: Schedule It with a Trigger (Optional)

Running the script by hand is fine, but automation truly shines when it runs on a schedule.

  1. In the Apps Script editor, click Triggers (clock icon on left).
  2. Click Add Trigger.
  3. Choose:
    • Function: addTimestampAndStatus
    • Event source: Time-driven
    • Type: Hour timerEvery hour (or your preference)
  4. Save.

Now your script runs automatically—no clicks required!

Troubleshooting Tips

  • Script won’t run? Make sure you granted permissions during the first run.
  • Wrong column? Double-check the column numbers in getRange(row, column).
  • Quota limits? Free Google Workspace accounts have daily quotas. Keep scripts efficient and batch operations where possible.

Key Takeaways

  • Google Apps Script can automate Google Sheets in just a few lines of code.
  • Use time-driven triggers to run tasks on a schedule.
  • Start small—automate one repetitive task, then build from there.

What’s Next?

In future posts, we’ll cover:

  • Sending personalised emails directly from Sheets.
  • Building custom menus and sidebars.
  • Connecting Google Sheets to external APIs.

Have an automation idea? Share it in the comments below, and we might feature your challenge in an upcoming tutorial!


Liked this guide? Subscribe to Blogmines.com for weekly tutorials on Google Apps Script, Microsoft Office VBA, and iOS Shortcuts—all in simple English.


Questions? Corrections? Issues and pull requests are always welcome.

This post is licensed under CC BY 4.0 by the author.