Run Macro Based On Combobox Selection

Guard913

Board Regular
Joined
Apr 10, 2016
Messages
144
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Don't let the title confuse you, this is more complex than you think..... I have a combobox with code:
(FYI this code works perfectly No Changes please)

Code:
Sub UserForm_Initialize()
With ComboBox2
.AddItem Worksheets("Sheet3").Range("A17").Value
End With
End Sub

However, Imagine that there are several extra items in this list. Range A17 will change regularly to a different set of terms/items along with all the other add items (each will be calling from a different cell (and possibly sheet), and will have different information) I need a code that will allow me to run a macro based on the selection with this in mind, and as the name changes all the time using format:

Code:
If Me.Combobox2.Value = "(Static Text)" Then
Call "macro name"
Range("B2").Select
End If

Won't work, as cell A17 will rarely if ever equal the same thing more than 1 time and changes every 10-15mins. I am thinking the code might be similar to:

Code:
If Me.Combobox2.Value = "Worksheets("Sheet3").Range("A17").Value" Then
Call "macro name"
Range("B2").Select
End If

However that does not work.... Please Help...

EDIT: (I think I got it, any suggestions)

Code:
If Me.Combobox2.Value = Worksheets("Sheet3").Range("A17").Value Then
Call "macro name"
Range("B2").Select
End If
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

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