Louise has attended:
Excel VBA Intro Intermediate course
Combo box selections
How do you create a code for selecting multiple values in a drop down box - for example when you hold down ctrl and the make your selection
RE: Combo box selections
Hi Louise,
Thank you for your question.
As far as I am concerned, you cannot select multiple options from a combo box. However if you create a listbox you can change the MultiSelect property to 1-frmMultiSelectMulti.
Use the code we created to populate the values in the listbox based on the report type chosen.
This will then allow you to use the Ctrl and Click technique to select more than one value.
I hope this answers your question.
Regards
Simon
RE: Combo box selections
Hi Louise,
Please find below some code that displays a message box with the multiple values you select from the list box.
Private Sub CommandButton1_Click()
strMsg = "You chose the following entries form the list box:" & vbCrLf
For i = 1 To lbentries.ListCount
' works out how many values in list
If lbentries.Selected(i - 1) = True Then
' if the first value is selected then...
strMsg = strMsg & lbentries.List(i - 1) & vbCrLf
'msgbox will show the message and the entry
End If
Next i
'this is the loop and it moves and checks for the second entry to have been selected and keeps looping until you click the command button.
MsgBox strMsg
'the result will be a message box that will display the message and the multiple values selected.
I hope this helps.
Regards
Simon