Multiple Sheets Action. Use Macro Recorder 🔴

Max Makhrov
1 min readJul 29, 2021

--

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.

Code:

Before you start.

  1. Record macro and perform the action on a single sheet.
  2. Edit code settings
// 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) {
sheet.getRange('A1').setValue('Yay!');
console.log(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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Max Makhrov
Max Makhrov

Written by Max Makhrov

Google Sheets Developer, automation expert

No responses yet

Write a response