• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to run multiple forms in sequence

meenakshi

New Member
Hai,
I have 4 form buttons in my excel which are to be clicked in sequence. CAn any one help out with macro to call those forms so that i can create short key on key broad61039 to execute the same action
 
Hi !​
You could first hide all button except the #1.​
When its procedure is launched, you could hide the first button and unhide the second one …​
Or better just use a single button and at each step you just have to change the text of the button​
and control in the procedure when it starts the stuff to achieve according to the text button.​
 
Presumably those buttons each have a macro assigned to them.
Let's say that the first button calls Macro1, the 2nd button calls Macro2, the 3rd button calls Macro3 and the 4th button calls Macro4.
Write a new Macro thus:
Code:
Sub RunEmAll()
Macro1
Macro2
Macro3
Macro4
End Sub
Now with the Excel GUI active (not the VBA editor), press Alt+F8 and highlight the RunEmAll macro, then click Options…, choose your shortcut, click OK, click Cancel.
 
Hi !​
You could first hide all button except the #1.​
When its procedure is launched, you could hide the first button and unhide the second one …​
Or better just use a single button and at each step you just have to change the text of the button​
and control in the procedure when it starts the stuff to achieve according to the text button.​
thanks for reply but i want a macro to run all these forms not hide them.
 
Presumably those buttons each have a macro assigned to them.
Let's say that the first button calls Macro1, the 2nd button calls Macro2, the 3rd button calls Macro3 and the 4th button calls Macro4.
Write a new Macro thus:
Code:
Sub RunEmAll()
Macro1
Macro2
Macro3
Macro4
End Sub
Now with the Excel GUI active (not the VBA editor), press Alt+F8 and highlight the RunEmAll macro, then click Options…, choose your shortcut, click OK, click Cancel.
Hai,
Thanks a lot for the reply. I tried. but error came. THose forms have sub but not macros. i am getting following error.
 

Attachments

  • Untitled.png
    Untitled.png
    93.7 KB · Views: 8
So your button will probably have event handler macros like
Private Sub CommandButton1_Click()

Change Private to Public:
Public Sub CommandButton1_Click()

Then you can have in a standard code-module the likes of:
Code:
Sub runEmAll()
Sheet1.CommandButton1_Click
Sheet1.CommandButton2_Click
Sheet1.CommandButton3_Click
Sheet1.CommandButton4_Click
End Sub
Be aware that code in a sheet code-module, any unqualified range references refer to that sheet (which is probably what you want) but if you've used the likes of ActiveSheet.range… in that code and since you can call this macro from a keyboard shortcut, the code may not act on the sheet you want it to.

Perhaps if you supply your code (not just the calling code) we can advise. Better still the workbook with the code - it will answer many question we may have, although if there's sensitive material you don't want in the public domain in the sheets you can alter or delete it.

It looks like your macros such as Empty_Stamps_Folder are residing in a sheet's code module? Or perhaps they're Private subs too in another module?
 
Back
Top