How to I combine multiple macros to create one Google Apps Script?

1,783 views
Skip to first unread message

Don Yerks, Jr.

unread,
Feb 27, 2021, 12:02:19 PM2/27/21
to Google Apps Script Community
Hello Everyone,

Any advice on how to do this would be greatly appreciated!

How could I use already created macros and turn them into a Google Apps Script? I was working on a spreadsheet that eventually had 5 Macros. I had to run each macro individually :-( 

I was wondering if there was a way of combining those macros into one Google Apps Script, so I could just click the run function and all five macros would run at one time. 

It would be wonderful if you could share how to do something like this in a video or an online post?

Please & Thank You for any and all suggestions!

Don Yerks

CBM Services

unread,
Feb 27, 2021, 12:22:51 PM2/27/21
to google-apps-sc...@googlegroups.com
Hi Don,

A Macro is actually an Apps Script function.

If you would like to create a function that runs them all, it is very simple to do so. Just create a new function and invoke the macros by their name in the order that you want. Example below:

function newFunction() {

  macro1();

  macro2();

  macro3();

}

Once you run the new function "newFunction" it will execute  the 3 macros in the specific order. You can add as many as you want. Just be careful of syntax (semicolon at end of each line)

Good luck.

From: Don Yerks, Jr.
Sent: ‎2021-‎02-‎27 9:02 AM
To: Google Apps Script Community
Subject: [Apps-Script] How to I combine multiple macros to create one GoogleApps Script?

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/f628c622-27db-4f4e-953a-e04bc714840do%40googlegroups.com.

Don Yerks, Jr.

unread,
Feb 27, 2021, 5:02:12 PM2/27/21
to Google Apps Script Community
Hi George,

Thanks for getting back to me.

I tried it ...

Sadly I didn't get it to work.

It's me, not your suggestion.

I did try to record all the macros in one recording session and it created what you suggested in the script code.

I'll keep trying.

Thanks,
Don Yerks

CBMServices Web

unread,
Feb 27, 2021, 8:32:33 PM2/27/21
to google-apps-sc...@googlegroups.com
If the macros are recorded in different sheets/files, just copy them and paste them into one sheet so you can invoke them directly. Just make sure that each function has a unique name within the file.

Thanks.

Reply all
Reply to author
Forward
0 new messages