combo box selections
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Combo box selections

resolvedResolved · Low Priority · Version 2003

replyReply Fri 12 Jun 2009, 16:10Delegate Louise said...

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

For upcoming training course dates see: Pricing & availability

replyReply Wed 17 Jun 2009, 14:43Trainer Simon said...

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

replyReply Wed 17 Jun 2009, 15:54Trainer Simon said...

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.

 

Please browse our web site to find out more about
excel consultants and other Microsoft training courses.

Excel tip:

Change the Print button so it brings up the Print dialogue box

If you want to bring up the Print dialogue box to check your print settings when you hit the Print button, do the following:

1. Right-click on the toolbar that displays the Print button.

2. Select Customise.

3. Click on the Print button on the toolbar to select it, then hold the left mouse button down and drag the button towards the screen below. The button should come off the toolbar.

4. In the Customise dialogue box on your screen, select the Commands tab.

5. Select File from the Categories list, and then locate the Print... icon (looks like the normal Print button, but the word Print has three dots following it).

6. Click on the Print... icon to select it, then use your left mouse to drag and drop the icon onto the toolbar at the top of the screen.

7. Close the Customise dialogue box.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard