Summarize data from multiple sheets

Stay organized with collections Save and categorize content based on your preferences.

Coding level: Beginner
Duration: 5 minutes
Project type: Custom function

About this solution

If you have similarly structured data on multiple sheets in a spreadsheet, such as customer support metrics for team members, you can use this custom function to create a summary of each sheet. This solution focuses on customer support tickets, but you can customize it to fit your needs.

Screenshot of the getSheetsData function output

How it works

The custom function, called getSheetsData(), summarizes data from each sheet in the spreadsheet based on a sheet's Status column. The script ignores sheets that shouldn't be included in the aggregation, such as the ReadMe and Summary sheets.

Apps Script services

This solution uses the following service:

  • Spreadsheet Service: Gets the sheets that need to be summarized and counts the number of items that match a specified string. Then, the script adds the calculated information to a range relative to where the custom function was called in the spreadsheet.

Before you begin

To use this sample, you need the following prerequisites:

  • A Google Account (Google Workspace accounts might require administrator approval)
  • A web browser with access to the internet

Try it

  1. Click the button below to make a copy of the Summarize spreadsheet data custom function spreadsheet.
    Make a copy
  2. Go to the Summary sheet.
  3. Click cell A4. The getSheetsData() function is in this cell.
  4. Go to one of the owner sheets and update or add data to the sheet. Some actions you can try include the following:
    • Add a new row with sample ticket information.
    • In the Status column, change the status of an existing ticket.
    • Change the position of the Status column. For example, in the Owner1 sheet, move the Status column from column C to column D.
  5. Go to the Summary sheet and review the updated summary table that getSheetsData() created from cell A4. You might need to check the checkbox in row 10 to refresh the cached results of the custom function. Google caches custom functions to optimize performance.
    • If you added or updated rows, the script updates the ticket and status counts.
    • If you moved the position of the Status column, the script still works as intended with the new column index.

Open the Apps Script project

The sample script's code includes in-line comments to help you understand how it works. To access the code, in the spreadsheet, click Extensions > Apps Script.


You can edit the custom function as much as you'd like to fit your needs. Below is an optional addition to manually refresh custom function results.

Refresh cached results

Unlike built-in functions, Google caches custom functions to optimize performance. This means that if you change something within your custom function, such as a value that's being calculated, it might not immediately force an update. To refresh the function result manually, take the following steps:

  1. Add a checkbox to an empty cell by clicking Insert > Checkbox.
  2. Add the cell that has the checkbox as a parameter of the custom function, for example, getSheetsData(B11).
  3. Check or uncheck the checkbox to refresh the custom function results.


This sample is maintained by Google with the help of Google Developer Experts.