Inventory Manager Script for Google Sheets: Setup Guide

How-to basics · Updated December 1, 2026

An inventory manager script for Google Sheets is a custom Apps Script function or macro that automates stock tracking, reorder alerts, and data entry, saving hours of manual work. You can create one using Google Apps Script (Extensions > Apps Script) with built-in functions like onEdit triggers and SpreadsheetApp, no paid add-on required.

Why Use a Script Instead of Manual Tracking

Manual inventory in Google Sheets works for a few dozen items, but errors creep in as you add suppliers, SKUs, and sales logs. A script handles repetitive tasks instantly: it can deduct sold quantities when you mark a sale, flag low stock, and even email reorder alerts. Unlike formulas alone, scripts run on events (like editing a cell) and can loop over hundreds of rows without dragging formulas down. For example, a typical warehouse sheet with 500 SKUs and daily sales entries becomes error-prone within a week if you rely on manual updates—a script reduces that to near zero.

Core Script Components You Need

A practical inventory script usually combines three parts: a trigger, a data range, and an action. The most common trigger is an onEdit(e) function that fires whenever a user edits any cell. The data range defines where your SKU, quantity, and reorder threshold live. The action might update a quantity, write a timestamp, or send an email. Here is a minimal working example that subtracts sold units when you type a negative number in column C (with headers in row 1, SKU in A, quantity in B, and adjustment in C):

function onEdit(e) {
  var sheet = e.source.getActiveSheet();
  var range = e.range;
  var col = range.getColumn();
  var row = range.getRow();
  if (col === 3 && row > 1) {
    var sku = sheet.getRange(row, 1).getValue();
    var currentQty = sheet.getRange(row, 2).getValue();
    var adjustment = range.getValue();
    if (typeof currentQty === 'number' && typeof adjustment === 'number') {
      sheet.getRange(row, 2).setValue(currentQty + adjustment);
      sheet.getRange(row, 4).setValue(new Date()); // timestamp in D
    }
  }
}

This script assumes your sheet has data starting at row 2. It adds the adjustment (so a negative number reduces stock) and logs the edit time. To install it, open Extensions > Apps Script, paste the code, click Save, and then run it once to authorize permissions. The trigger works automatically after that.

How to Set Up a Full Inventory System

For a more complete system, you’ll want a separate “Sales Log” sheet and a “Products” sheet. The script reads the sale entry, finds the matching SKU, and updates the product quantity. Here’s a step-by-step approach:

  • Create a sheet named “Products” with columns: SKU, Name, Category, Quantity, Reorder Point, Supplier Email.
  • Create a sheet named “Sales” with columns: Date, SKU, Quantity Sold.
  • In Apps Script, write a function that reads the last row of Sales, gets the SKU and quantity, then finds that SKU in Products and subtracts the quantity.
  • Add a check: if the new quantity is below the reorder point, send an email using MailApp.sendEmail() to the supplier address.
  • Use a time-driven trigger (like every hour) to run a separate function that scans all products and sends a summary of low-stock items.

For email alerts, you need to enable the Gmail service in Apps Script (it’s automatic). A sample email function looks like this:

function sendLowStockAlert(sku, qty, supplierEmail) {
  var subject = 'Low stock: ' + sku;
  var body = 'Current quantity is ' + qty + '. Please reorder.';
  MailApp.sendEmail(supplierEmail, subject, body);
}

Choosing Between a Script, Formulas, or Add-ons

Formulas like =SUMIF or =QUERY can track totals but cannot send emails or react to edits. Add-ons like “Inventory Management” or “Sheetgo” offer pre-built features but often cost money and may not fit your exact workflow. A custom script gives full control, but requires basic coding knowledge. If you’re not comfortable with JavaScript, start with formulas and only script the one task that hurts most—like reorder alerts. For example, you can use conditional formatting to highlight low stock without a script, but you cannot automate an email. That’s the trade-off.

Common Problems and How to Fix Them

Three issues trip up most users: triggers not firing, wrong data types, and permission errors. If your onEdit script doesn’t run, check that you saved the project and that the function is named exactly onEdit (case-sensitive). If quantities are stored as text (e.g., “10 pcs”), the script’s typeof check fails—use Number() to convert. Permission errors happen when you haven’t authorized the script; click the “Run” button once and accept the prompts. Also, remember that onEdit triggers do not run when edits are made by another script or by an import (like from Google Forms), so you may need a separate time-driven trigger for those cases.

Costs, Safety, and Data Backup

Apps Script is free for personal use, but there are quotas: you can send up to 100 emails per day on a free Google account (200 for Workspace). Scripts run within 6 minutes per execution for simple triggers. For safety, always keep a backup of your spreadsheet before deploying a script—you can use File > Make a copy. Also, test the script on a copy with dummy data first. Never share your script with sensitive credentials; instead, use the script’s built-in properties service to store API keys securely. Finally, be aware that scripts run with your permissions, so don’t grant access to a script you don’t trust.

Alternatives to a Custom Script

If coding isn’t for you, consider these alternatives: Google Sheets’ built-in “Data validation” and “Conditional formatting” for visual alerts; Google Forms for simple sales entry (but no auto-update); third-party add-ons like “Inventory” by Sheetgo, which syncs multiple sheets and offers templates; or full inventory management software like Odoo or inFlow, which integrate with Sheets via API. For a small business, a script is often the cheapest and most flexible, but for complex multi-location tracking, dedicated software may be worth the cost.

Frequently Asked Questions

Can I use a script to scan barcodes into Google Sheets? Yes, you can use a barcode scanner that types into a cell (most USB scanners act as keyboards). The script can then look up the scanned SKU and update quantity. You’ll need to handle the enter key that scanners send—use an onEdit trigger or an installable onFormSubmit if using a form.

Will the script work on the Google Sheets mobile app? Simple onEdit triggers work on mobile, but they may be slower and some features like email dialogs are limited. Time-driven triggers work regardless of device. For heavy use, stick to a desktop browser.

How do I prevent someone from accidentally deleting data? You can add a script that checks if a row is being cleared and prompts for confirmation, but a simpler method is to protect ranges via Data > Protected sheets and ranges. Scripts can also create a backup copy every day using a time trigger.

Can I run the script on a schedule without manual intervention? Yes, go to Apps Script > Triggers (clock icon) > Add Trigger, choose your function, select “Time-driven” and pick an interval (e.g., hourly). This is useful for recalculating totals or sending daily reports.

What if I need to track multiple warehouses? You can add a “Location” column to your Products sheet and modify the script to filter by location. Alternatively, use separate sheets per warehouse and have the script loop through each. For advanced needs, consider a database like Firebase, but that’s beyond Sheets.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.