combo box selections

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

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

Combo box selections

resolvedResolved · Low Priority · Version 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:

Shortcuts for working with named ranges in Excel

If you are working with or creating named ranges in your spreadsheets, then you may find the following shortcut keys useful.

- Bring up the Define Names dialogue box on screen by using Ctrl + F3 (instead of going to Insert - Names).

- Create Names from labels you have entered into the spreadsheet by highlighting the labels and related figures, then hold down Shift + Ctrl + F3. You can then choose to create names from the top or bottom rows, or left or right columns.

- Go directly to a named range by hitting the F5 key. The Go To dialogue box will open and display any named ranges in the spreadsheet. Simply select the named range to navigate to it in the spreadsheet.

View all Excel hints and tips


Server loaded in 0.09 secs.