I currently have a script I am using in the script editor for over 20 spreadsheets. Every time I make a change to one, I have to make a change to the other 19. Is there a way to use one script and reference the rest so that any change I make I only have to do it to one?
1 Answer
Yes. Use a Library. In your code editor, choose the FILE menu item, and PROPERTIES. A dialog box will pop up. Copy out the project key. Now go to RESOURCES, LIBRARIES, and a dialog box will pop up. In sheets that will not have the original code, enter the project key of the Apps Script, that has the main code.
https://developers.google.com/apps-script/guide_libraries
Keep in mind that there is nothing special you need to do to create a "Library". All a Library is, is code that you've already created. You are just using the Project Key.
2 Comments
User125
awesome. Thank you. So for sheets that do not have the code do i have to set up the triggers again? I have onedit triggers set for the original script.
Alan Wells
Good question. I'm not sure. You might need to experiment.