Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

combo box selections

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Combo box selections

Combo box selections

ResolvedVersion 2003

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

Wed 24 Jun 2009: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Viewing two Excel 2010 Workbooks at the same time

Did you know you can view two Excel 2010 workbooks side by side? Very useful when comparing data without constantly having to go back and forth!

1) Open both Excel workbooks
2) Select Window then select Compare Side by Side with (Spreadsheet 2)
3) When you have finished, select Window again and click Close Side by Side

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.