Hi,
I have a command button(cmdDerive) and a list box(listbox2) in a Microsoft Excel form. The list box has 11 items in it. When i select an item in the list box and click on the command button a calculation takes place.
I need to add code so that if i do not have an item in the list box selected then it will display a message box telling the user they must select an item.
Private Sub cmdDerive_Click()
Dim index
For index11 = 0 To ListBox2.ListCount - 1
If ListBox2.Selected(index11) = True Then
If ListBox2.List(index11) = "Dqwi1" Then
Call Dqwi1
ElseIf ListBox2.List(index11) = "Dqwi2" Then
Call Dqwi2
ElseIf ListBox2.List(index11) = "Dqwi3" Then
Call Dqwi3
ElseIf ListBox2.List(index11) = "Dqwi4" Then
Call Dqwi4
ElseIf ListBox2.List(index11) = "Dqwi5" Then
Call Dqwi5
ElseIf ListBox2.List(index11) = "Dqwi6" Then
Call Dqwi6
ElseIf ListBox2.List(index11) = "Dqwi7" Then
Call Dqwi7
ElseIf ListBox2.List(index11) = "Dqwi8" Then
Call Dqwi8
ElseIf ListBox2.List(index11) = "Dqwi9" Then
Call Dqwi9
ElseIf ListBox2.List(index11) = "Dqwi10" Then
Call Dqwi10
ElseIf ListBox2.List(index11) = "Dqwi12" Then
Call Dqwi12
End If
End If
Next index11
End Sub
I tried adding this code in a few places but it did not work correctly:
If ListBox2.Selected(index11) = False Then
MsgBox "You must select a derived variable."
End If
Thanks,
Mike
I have a command button(cmdDerive) and a list box(listbox2) in a Microsoft Excel form. The list box has 11 items in it. When i select an item in the list box and click on the command button a calculation takes place.
I need to add code so that if i do not have an item in the list box selected then it will display a message box telling the user they must select an item.
Private Sub cmdDerive_Click()
Dim index
For index11 = 0 To ListBox2.ListCount - 1
If ListBox2.Selected(index11) = True Then
If ListBox2.List(index11) = "Dqwi1" Then
Call Dqwi1
ElseIf ListBox2.List(index11) = "Dqwi2" Then
Call Dqwi2
ElseIf ListBox2.List(index11) = "Dqwi3" Then
Call Dqwi3
ElseIf ListBox2.List(index11) = "Dqwi4" Then
Call Dqwi4
ElseIf ListBox2.List(index11) = "Dqwi5" Then
Call Dqwi5
ElseIf ListBox2.List(index11) = "Dqwi6" Then
Call Dqwi6
ElseIf ListBox2.List(index11) = "Dqwi7" Then
Call Dqwi7
ElseIf ListBox2.List(index11) = "Dqwi8" Then
Call Dqwi8
ElseIf ListBox2.List(index11) = "Dqwi9" Then
Call Dqwi9
ElseIf ListBox2.List(index11) = "Dqwi10" Then
Call Dqwi10
ElseIf ListBox2.List(index11) = "Dqwi12" Then
Call Dqwi12
End If
End If
Next index11
End Sub
I tried adding this code in a few places but it did not work correctly:
If ListBox2.Selected(index11) = False Then
MsgBox "You must select a derived variable."
End If
Thanks,
Mike