SheetCommand · Spreadsheet automation and analysis

Google Sheets Apps Script: a beginner automation example

Use an onEdit trigger in Google Sheets and understand its limits.

Google Apps Script automates Google Sheets and other Google apps with JavaScript. It is different from Excel VBA macros. SheetCommand runs only its listed commands on uploaded spreadsheet data; it cannot execute scripts.

Where does Apps Script run?

Open Extensions > Apps Script in Google Sheets to create a script attached to that spreadsheet. Review any permissions that Google requests before running code.

Uploading an XLSX file to SheetCommand does not run Apps Script. Likewise, code written for Google Sheets will not automatically run as an Excel VBA macro.

Write a timestamp after an edit

This simple trigger writes a timestamp into column B when someone manually edits column A on a sheet named Data. It ignores the header row.

The example replaces any existing value in the matching B cell. Test it on a copy. Changes made by scripts do not re-trigger the simple onEdit function.

How to do it

  1. Open Extensions > Apps Script in a Google Sheet.
  2. Add the example to the bound project and save.
  3. Manually edit A2 on a test sheet named Data and check B2.
Example code
function onEdit(e) {
  const cell = e.range;
  if (cell.getSheet().getName() !== 'Data' || cell.getColumn() !== 1 || cell.getRow() < 2) return;
  cell.getSheet().getRange(cell.getRow(), 2).setValue(new Date());
}

Choose the right tool

Use Apps Script for repeated workflows inside Google Sheets. Excel VBA and Office Scripts are different technologies for supported Excel environments.

SheetCommand does not run Apps Script, VBA, Office Scripts, or macros. Pasting code into its command box returns an unsupported operation; use its listed summary, cleanup, and sorting commands instead.

Frequently asked questions

Is App Script the same as Apps Script?

People often search for App Script, but Google's product name is Apps Script.

Can SheetCommand run Apps Script?

No. It processes uploaded table data using its own supported commands; Apps Script runs in Google's environment.

Sources and further reading

SheetCommand

Clean data before automating

Use a supported command to inspect rows and remove fully blank records from the source table.

Use for free →