Multiple Sheets Action. Use Macro Recorder 🔴

The idea: perform the same action on multiple sheets. The idea is not new, my approach was to use macro each time to see the correct code snippet. It was useful and saved me hours on my current project.


Before you start.

  1. Record macro and perform the action on a single sheet.
// change these settings
var performSets = {

// change to any Spreadsheet if needed
// default: active sheet
file: SpreadsheetApp.getActive(),

// regular expression to find
// sheets for action
re: /^Sheet.*/,

// function to perform on each sheet
func: function(sheet, sheetName) {

Change the regular expression to match sheets names, or change the function getSheetMatchs to match your list of sheets.

Change the function to perform with each sheet. ⚠️Caution! Be attentive in this stage to perform the correct action.

Next: Run the code!

Photo by Mick Haupt on Unsplash

Google Sheets Developer, master of Online Accounting