Multiple ComboBox help

wisemank

Board Regular
Joined
Jun 21, 2010
Messages
129
Hello again, I have a Userform with two ComboBoxes. The ComboBox1, when selected shows all open excel files which the user chooses one which they want to perform the next function. ComboBox2 needs to declare what file source so the proper macro can be executed. I have ComboBox 1 and the execution working, but ComboBox2 is not functioning properly. See BOLDED area below. Any ideas would be appreciated. Thanks....Option Explicit
Public MyFile As String
Public Stopped As Boolean
Private Sub CommandButton1_Click()
Unload Me

End Sub
Private Sub CommandButton2_Click()
Stopped = True
Unload Me

End Sub
Private Sub Image1_Click()
Stopped = True
Unload Me

End Sub
Private Sub Image2_Click()
If ComboBox1 = vbNullString Then
MsgBox "All Fields are Required!"
ComboBox1.SetFocus
Exit Sub
End If

MyFile = Me.ComboBox1.Value
Select Case ComboBox2.Value

Case "1"
Application.Run "MacroToImportFCTVBOM"
Case "2"
Application.Run "MacroToImportFCCST"
Case "3"
Application.Run "MacroToImportVAMR"
Case "4"
Application.Run "PCSCopySheet"


End Select


Unload Me

End Sub
Private Sub UserForm_Initialize()
Dim wkb As Workbook
Me.Label1.Caption = "Please select one of the following files..."
With Me.ComboBox1
For Each wkb In Application.Workbooks
.AddItem wkb.Name
Next wkb
End With

With ComboBox2 'Model Year
.AddItem "FastCar - Tracked Vehicle Report"
.AddItem "FastCar - Cost Service Tool"
.AddItem "VAMR"
.AddItem "Product Cost Study"

lbl_exit:
End With


End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try using the ComboBoxes ListIndex property & see if that solves your problem.

Code:
Select Case ComboBox2.ListIndex
    Case 0
        Application.Run "MacroToImportFCTVBOM"
    Case 1
        Application.Run "MacroToImportFCCST"
    Case 2
        Application.Run "MacroToImportVAMR"
    Case 3
        Application.Run "PCSCopySheet"
    End Select

Dave
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,229
Members
448,879
Latest member
VanGirl

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