Skip to content
Advertisement

Google Apps Script – Loop to Update Multiple Named Ranges Based on Reference Table

First off, I realize that there are ways to do this without using named ranges and scripts. Sadly, Google Docs imported ranges strongly disagrees so I need to find a way to make this work.

I think I’m nearly there with this script, but I lack the coding knowledge for even basic loops in GAS. I highlighted the related section of the spreadsheet in blue that is involved with the script and shared an example at this link:

On edit of a particular cell, I would like the following to happen:

  • Grab a list of named ranges from a range of cells in a particular spreadsheet
  • Update the ranges for those named ranges from an adjacent range of cells in the same spreadsheet

I understand the concept of using setNamedRange() one by one but not in a loop based on spreadsheet ranges. I would like this to be expandable, so that I can easily expand the number of ranges that I can update with this script.

JavaScript

Update 1

Figured out a working solution thanks to Yuri! Here is my final code. I also added a tweak so that the onEdit trigger is tied to a specific sheet.

JavaScript

Advertisement

Answer

Something like this?

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement