View Full Version : VBA code to run other macros
simplemanny
07-30-2015, 08:41 AM
Im looking to creat a vba code that runs other macros in a particuler other with the click of a button. This lets say we have 4 macros in 4 different sheets running on diffent buttons. how can we make a vba code to run the different macros in a particular order consectively to be intergated in a buttton.
Thank You in advance.
p45cal
07-30-2015, 10:27 AM
Activex Buttons or Form buttons? If you right-click a button and one of the choices is Assign Macro then you have a Forms button. If you do the same with an activeX button you will see one of the options being View code.
simplemanny
07-30-2015, 10:34 AM
form buttons. Thank you.
p45cal
07-30-2015, 11:02 AM
That makes things easier.
When you add a forms button you might assign any existing macro to that button.
Let's say you have some macros that are assigned to a few buttons: Macro1, Macro2 etc.
Create a macro to assign the button which is going to call the same macros as the other buttons do individually, you have something like:
Sub myBigMacro()
Macro1
Macro2
End Sub
Excel typically might suggest a macro name such as Sheet2_Button1_Click, but these are no different from any other standard macro.
Now it gets a bit more complicated if you want to pass arguments…
ps. you haven't cross-posted without telling us have you?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.