VBA: Need to run certain macro based off of Userform Combobox selection

NikoleJay

New Member
Joined
May 9, 2020
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hello!

What I have so far is a list of modules that have macros for a specific month. I made a userform with a combobox (name: SelectMonth) that lists the months for the user to select. The idea is to run the macro for the month that is selected, but I am getting "Compile error: Expected variable or procedure, not module." The code I am using is one that I found from another forum, but I'm not sure what I'm missing. Below is the code I am using.

The actual modules are named:
Bldg_InitialReconcilerCopy_June
Bldg_InitialReconcilerCopy_July
Bldg_InitialReconcilerCopy_Aug

And the macros are named:
June_Bldg_InitialReconcilerCopy
July_Bldg_InitialReconcilerCopy
August_Bldg_InitialReconcilerCopy

I tried to call it by the module name and macro name, but received the same error. If anyone can let me know what I need to do to fix it, I would greatly appreciate it!

VBA Code:
Private Sub CommandButton1_Click()
If SelectMonth.Value = "June" Then
    Call Bldg_InitialReconcilerCopy_June
End If
If SelectMonth.Value = "July" Then
    Call Bldg_InitialReconcilerCopy_July
End If
If SelectMonth.Value = "August" Then
    Call Bldg_InitialReconcilerCopy_Aug
End If
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You need to use the macro name like
VBA Code:
Call  June_Bldg_InitialReconcilerCopy
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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