'Google sheets shared macro file

I have about 70 different google sheets files and they need to be separate files. They all use the same macros, right not I am coping the macros into each sheet file and if I need to change something I have to change it in the macros for each of the 70 files. Is there a way like a dll that I can have all files have access to the same macro file. There are multiple different macros in this file and are quite complex, they do things onEdit and they add a new menu, etc.



Solution 1:[1]

You can deploy a standalone script

How to apply it depends on your situation, but assuming you write once something like:

const spreadsheetIds = ["AAA", "BBB", "CCC"];

function applyToAllSheets(){
 spreadsheetIds.forEach(function(id){
   var ss = SpreadsheetApp.openById(id);
   runFunction(id);
  })
}

function runFunction(){
  ss.getActiveRange().setValue("Hello World");
}

You can modify the content of runFunction() and then, when you run applyToAllSheets() - runFunction() will be executed for all spreadsheets with the ids specified in const spreadsheetIds.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ziganotschka