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
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