working with sheets
Code snippets to help you automate common tasks
Examples of use
Sometimes, you will want to use Apps Script to automate modifying a sheet in its own right, e.g to carry out a complicated sort or apply a long sequence of cell formattings. Or you might want to create your own bespoke function for performing a calculation within a cell.
More often, however, a sheet will be where you store the data that a script will use to carry out other actions, such as modifying a Google Classroom course. It might also be where the script outputs a summary of its actions to — as described in Apps Scripts Fundamentals, scripts have no memory and so every execution is a fresh run of the original script. You might therefore need somewhere to record what happened in the previous execution, ready for the next.
-
Automatically authorise the Importrange function

Learn how to use Google Apps Script to automate allowing permission for the IMPORTRANGE function in Google Sheets.
-
Case study #3: Email home a class set of mail-merged reports

Learn how to generate personalised student reports using mail merge in Word and then automate sending them home to parents using Apps Script
-
Case study #2: Automate YouTube subscriptions

A full script example to show sharing a list of YouTube channels (e.g. vetted subject-specific ones) and automating subscribing to each.
-
Read in data from a sheet

Read data from a range of cells on a sheet, ready for your script to process.
-
Add a custom menu

Add your own menu to Sheets (or Docs, Slides or Forms) to run functions in your script.
Share this via: