Excel VBA UserForm with ListBoxes (multiple Selections) - Unable to clear Multiple Selections

GSeibert

New Member
Joined
Apr 11, 2016
Messages
3
Hi there,
I've created an Excel Worksheet for collecting information.

Keeping it to just this as simple as possible.. I have a UserForm with several different types of selection options but mostly ListBoxes with multiple selections option turned on.

I don't seem to have the correct code to clear all of the previous selections.

I don't want it to automatically clear the whole input, but I do want the form to clear the whole form when I choose that option. It does clear single entry fields, but not the multi-selection List Boxes.

Any suggestions? Thank you,

G.Seibert
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You would have to Loop through the entries on the listbox and clear them if they are currently selected

The code should look something like this
Code:
Private Sub CommandButton1_Click()
    For I = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(I) = True Then
            ListBox1.Selected(I) = False
        End If
    Next I
End Sub
 
Upvote 0
What about using something like....

Me.LstBxInOut1.MultiSelect = fmMultiSelectSingle
Me.LstBxInOut1.Value = ""
Me.LstBxInOut1.MultiSelect = fmMultiSelectMulti

... for each ListBox? I just found this... I'm hoping there might even be a better plan. And, Thank you so much for responding so quickly!
 
Upvote 0
Here's another method to 'reset' a multiselect listbox.
Code:
    ListBox1.List = ListBox1.List
 
Upvote 0

Forum statistics

Threads
1,223,637
Messages
6,173,488
Members
452,515
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top