Inserting a Dialog Box to Call Other Macros

FrenchCelt

Board Regular
Joined
May 22, 2018
Messages
135
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'd like to code a macro that essentially causes a dialog box to pop up with a few options to select from, each selection calling a different macro already stored, as a way to consolidate the use of several similar macros under one shortcut key command instead of having to remember all the different shortcut keys for each variation.

Does anyone have any coding suggestions? For example, for the one I want to start with, I have two macros to select from. I'd like the dialog box to ask the user to select from either:

10A/10B Reports

or

12A/12B Reports.

If 10A/10B is selected, then the macro should Call 10A/10B Report.
If 12A/12B is selected, the the macro should Call 12A/12B Report.
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
Office Version
  1. 365
Platform
  1. Windows
You could use a userform that lists the names, or pseudo-names, of the macros you want to run in a listbox.

The user could then select the macros they want to run, click a button and then the code behind the button could use Application.Run to execute the selected code.
 

FrenchCelt

Board Regular
Joined
May 22, 2018
Messages
135
Office Version
  1. 365
Platform
  1. Windows
I would rather stick with using a macro since everyone involved is familiar and comfortable with that. It was hard enough teaching everyone how to use macros...introducing the Developer tab just increases complexity.

I do have some preliminary code from a colleague that works, but not ideally:

VBA Code:
Dim mres As String
    mres = MsgBox("Select ""Yes"" for 10A/B Reports ""No"" for 12A/B Reports ""Cancel"" to Exit", vbYesNoCancel, "Throughput Reports")
    Select Case mres
    Case vbYes
    Call Throughput_Report_Format_2016_10A_10B
    Case vbNo
    Call Throughput_Report_Format_2016_12A_12B
    Case vbCancel
    Exit Sub
    End Select

I dislike having it be a Yes/No choice. I'd prefer the text for each button to say 10A/B and 12A/B. Another problem I'm having with this code is that it works fine if selected from the View Macros list, but when I assigned a shortcut key and activated it, the code defaulted to the 10A/B macro without displaying a message box.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,216
Office Version
  1. 365
Platform
  1. Windows
Why not have a button that they can press that pops up the userform?

Then they wouldn't need to go near the Developer tab or the Macros dialog.:)
 

Watch MrExcel Video

Forum statistics

Threads
1,122,436
Messages
5,596,106
Members
414,042
Latest member
Swiftkoala

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
Top