input box to call several macros?

edlim85

Board Regular
Joined
May 4, 2009
Messages
178
Hi all,

I understand i can call several macros using the example below. But Say in a bunch of macro(Macro A, B, C, D) i only want to call A and B. Using a input box, how shld i code this?


Sub RunAll() Call Macro1 Call Macro2 Call Macro3 ...so on End Sub</pre>
pls advise


Sincerely
Edmund
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Edmund,

You could use something along these lines to run a selection of macros.

Code:
Sub runMacros()
    Dim macrosToRun As String
    Dim runThese As Variant
    Dim runThis As Variant
    
    macrosToRun = InputBox("Enter the Name(s) of macro(s) to run." & vbCr & "Seperate by COMMAS ','")
    '// Removed spaces as to avoid possible input error
    runThese = Split(Replace(macrosToRun, " ", ""), ",")
    
    For Each runThis In runThese
        On Error Resume Next
        Application.Run runThis
        If Err.Number <> 0 Then
            MsgBox runThis & " - was not found or an error occured"
        End If
    Next runThis
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,253
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top