Google-sheets – How to use the Google scripts on all the sheets

google sheetsgoogle-apps-script

I created a Google Sheets script (actually copied and pasted it).

It works on the sheet I was when I created the script, but not on others.

  1. Is there a way to "activate" the script to another sheet?

  2. Is there a way to make the script global to all my sheets?

I do not wish to copy and paste it to multiple sheets if avoidable, and I do not wish to publish it because I do not have the rights to it.

Best Answer

I think there are a couple of options; they might not be ideal but could work.

If by "to activate" the script you mean to authorize it, you can make a trigger that auto runs a function inside the script once the spreadsheet is open https://developers.google.com/apps-script/guides/triggers/

Having said that, to run your script in another spreadsheet and make it globally available to you, you could use libraries; take a look at this other link https://developers.google.com/apps-script/guides/libraries.

  1. First you create your library in a separate script (this would need copy paste).
  2. Once you have your library, you can import it to other Apps Script projects or spreadsheets.

The downside to this is that you would still need to open the script editor and write minimal code to import your library, so it might not be exactly what you want but I hope it helps.