Google Sheets Apps Script Documentation: How to Use It

How-to basics · Updated November 3, 2026

Google Sheets Apps Script Documentation: How to Use It

Google Sheets Apps Script documentation is available in Google’s official Apps Script developer documentation, especially the Spreadsheet service reference at developers.google.com/apps-script/reference/spreadsheet. It explains how to automate Sheets with JavaScript; open a spreadsheet and choose Extensions > Apps Script to create or access a script attached to that file.

Which documentation should you use?

There are several Google resources that sound similar but answer different questions. The right one depends on whether you want to write a script, use a Sheets feature, or connect to spreadsheets from another application.

  • Apps Script documentation covers the scripting platform, its editor, authorization, services, triggers, deployments, and quotas.
  • The Spreadsheet service reference documents Apps Script classes and methods for working with spreadsheet files, sheets, ranges, charts, and related objects.
  • The Google Sheets API documentation covers a separate web API for applications that access Sheets over HTTP, often using a client library or REST requests.
  • Google Sheets Help is aimed at spreadsheet users and explains interface features such as formulas, formatting, filters, and sharing.

A useful starting point for a coding task is the Apps Script overview, followed by the relevant service reference. For example, a script that reads cells needs the Spreadsheet service; it does not need the Sheets API simply because the data is in Google Sheets.

What Apps Script does for Sheets

Apps Script is Google’s cloud-based JavaScript platform for automating and extending Google Workspace products. In Sheets, it can read and change cell values, apply formatting, create menus and dialogs, respond to certain events, and interact with other supported services. The script runs on Google’s servers rather than as a desktop macro inside a browser tab.

Scripts can be bound to a particular spreadsheet or created as standalone projects at script.google.com. A bound script is convenient when automation belongs to one workbook: people with suitable access can find it through Extensions > Apps Script. A standalone script is useful when a project should be managed separately or work with files selected by code. The project type affects how the script finds its spreadsheet and how it is shared, but both use Apps Script services.

Apps Script uses JavaScript with Google’s V8 runtime. The documentation includes language and platform guidance, but spreadsheet-specific operations are provided through services such as SpreadsheetApp. The reference is organized by classes and methods: a class represents an object, such as a spreadsheet or range, and its methods perform operations on that object.

How the Spreadsheet service is organized

Most Sheets scripts follow a chain of objects. SpreadsheetApp is the entry point for spreadsheet operations. A spreadsheet contains sheets, a sheet contains ranges, and a range represents one or more cells. Methods such as getRange, getValues, and setValues let a script move from the file to the data it needs. The Spreadsheet service reference explains what each method accepts and returns.

Here is a small example. It reads a 3-by-2 area beginning at A1 and copies the values to a 3-by-2 area beginning at D1 on the active sheet:

function copyValues() {
  const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = spreadsheet.getActiveSheet();
  const values = sheet.getRange('A1:B3').getValues();
  sheet.getRange('D1:E3').setValues(values);
}

The source and destination ranges have the same dimensions, as setValues requires. getValues returns a two-dimensional array, even when the selected range is only one row or one column. That detail matters when transforming data: code must preserve the row-and-column shape expected by the destination. This example copies values, not formatting or formulas. Consult the Range reference for methods that address those separately.

For larger data sets, it is usually more efficient to read a range into an array, work with the array in JavaScript, and write the result back in one operation than to call the spreadsheet service repeatedly for individual cells. The official best-practices guide explains this pattern and other performance considerations.

Finding a method and checking its behavior

When searching the reference, start with the object you already have. If you have a Range, look at the Range class; if you need to locate a sheet, check the Spreadsheet class. Each method page generally describes parameters, return values, and usage. Follow links to related classes when a method returns another object. This is more reliable than copying a code fragment from an old forum answer without checking whether its assumptions fit your project.

Search the documentation using the exact method name when possible. For a task such as reading displayed text rather than underlying values, compare the relevant Range methods and their descriptions. Values, formulas, and displayed values are not interchangeable: a date may be represented internally as a value, shown using a number format, and produced by a formula. Choosing the correct method avoids subtle errors in exports and calculations.

Examples are helpful for seeing how methods fit together, but check the surrounding documentation for permissions, supported object types, and limitations. A method that works for a range in a standard spreadsheet may not apply to every chart, data source, or service. Documentation pages can also link to release notes and guides that explain platform-level behavior.

Creating a script and running it

  1. Open the spreadsheet in a web browser and choose Extensions > Apps Script. For a separate project, open script.google.com instead.
  2. Write a function in the editor and save the project. Use a clear function name and confirm that the code refers to the intended spreadsheet and sheet.
  3. Select the function in the editor and click Run. On a first run, Google may ask you to review and authorize the requested access.
  4. Check the execution details in the Apps Script editor if the run fails. Confirm the selected function, the range dimensions, and any error message before changing the code.

Running a function manually is different from making it run automatically. For a recurring task or event response, you may need a trigger. Simple triggers, such as a function named onEdit, have restrictions, including limits on services that require authorization. Installable triggers can access authorized services and are created by a user, but they run under the authority of the account that created them. The triggers guide explains these distinctions and how to configure them.

Authorization, sharing, and deployment

Apps Script requests authorization when a project needs access to Google services. The permissions depend on what the script does, and users should review the access prompt rather than treating it as a routine formality. A script that reads or modifies spreadsheet data may request spreadsheet access; a project that also sends email or accesses other services may need additional permissions. The Apps Script authorization guide explains scopes and consent.

Sharing a spreadsheet does not mean every collaborator has identical script permissions or ownership. Bound scripts are associated with their spreadsheet, but access to the file, permission to edit the script, and authorization to run services are related but distinct questions. Be cautious with code from an unknown source, especially if it asks for broad access. Review the code and requested permissions before authorizing it.

Deployment matters when a script is published for use beyond a manual run, such as a web app or an add-on. Deployment settings and access choices determine how an application is made available and whose identity it runs as in relevant cases. Do not assume that deploying a script automatically makes it public or that a spreadsheet’s sharing settings alone control every deployment. Check the deployment documentation for the specific project type.

Quotas, performance, and common errors

Apps Script has service quotas and execution limits. The limits depend on the service and account context, and Google can update them, so use the current quotas page rather than relying on a number remembered from an older guide. A script that works on a small test sheet may need adjustment when it handles many rows, makes frequent service calls, or runs on a schedule.

Common problems often have straightforward causes:

  • Authorization errors: the function may need approval, or a trigger may not have been created by an account with the required access.
  • Range size errors: the array passed to setValues may not match the destination range’s number of rows and columns.
  • Wrong spreadsheet or sheet: active spreadsheet and active sheet methods rely on context. Standalone or triggered scripts may need to open a file explicitly rather than assume a user has a sheet open.
  • Slow execution: repeated reads and writes to individual cells can be inefficient. Read and write blocks of values where appropriate.
  • Trigger surprises: simple and installable triggers have different permissions and execution behavior. Check the trigger guide and execution history.

Use the execution log and error details to identify the failing line. For intermittent or scheduled tasks, inspect execution history and trigger configuration as well as the code. Avoid assuming an error is caused by a spreadsheet formula; Apps Script errors and formula errors are reported through different mechanisms.

Apps Script versus the Sheets API

Apps Script and the Sheets API can both automate spreadsheet work, but they are not the same tool. Apps Script is often the simpler choice for code that lives with a spreadsheet, runs from a menu or trigger, or uses other Google Workspace services. It provides spreadsheet-specific objects and does not require you to build an HTTP client for ordinary operations.

The Sheets API is designed for applications that need to make requests to Sheets from outside the Apps Script environment. It offers API operations and client libraries for supported programming languages, and an application must handle authentication and requests according to the API documentation. An Apps Script project can also use advanced Google services where appropriate, but that does not make the two documentation sets interchangeable.

As a practical rule, choose Apps Script for a spreadsheet-centered workflow with modest setup and Workspace integration. Consider the API when Sheets is one part of a larger application, when you need an external language or server, or when API request patterns better fit your system. Compare authentication, deployment, quotas, and maintenance before choosing; the easiest option depends on where the automation will run.

Frequently Asked Questions

Where is the official Google Sheets Apps Script documentation?
Start at developers.google.com/apps-script for platform guides, then use developers.google.com/apps-script/reference/spreadsheet for the Spreadsheet service classes and methods.

How do I open Apps Script from Google Sheets?
In the spreadsheet’s web interface, choose Extensions > Apps Script. This opens the project associated with that spreadsheet if one exists, or lets you create a bound project.

Is Google Apps Script the same as the Google Sheets API?
No. Apps Script is Google’s hosted scripting platform with services for Sheets and other products. The Sheets API is an API for applications that make authenticated requests to spreadsheet data.

Can Apps Script run automatically when a cell changes?
Yes, using an edit trigger, but simple onEdit triggers have restrictions. Installable triggers offer different capabilities and authorization behavior; check the official trigger guide before choosing one.

Why does setValues return a range size error?
The two-dimensional array must match the destination range’s row and column dimensions. Check both shapes, and remember that getValues returns an array of rows even for a single-row range.

Does Apps Script cost extra?
Apps Script is a Google service, but available features and limits can depend on account type and product policies. Check current Google Workspace plans, service terms, and Apps Script quotas for the account you use.

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.