Loop through userform

P

Paul Morgan

I have a userform with 7 ListBoxes
6 listboxes are populated by the selection made from ListBox1(some
ListBoxes do not get populated all the time)
How can I clear(reset) ListBoxes 2 to 7, because some selections will
populate all the list boxes and some will only populate 1 or 2
listboxes, if a selection is made that populates all the listboxes,
then another is made that only populates 1 listbox, the other
listboxes are still populated because of not being cleared(reset)

Thanks
 
R

Rick Rothstein \(MVP - VB\)

ListBox'es have a Clear method which will remove the items in them. For
example,

ListBox2.Clear

should remove all the items in ListBox2.

Rick
 
P

Paul Morgan

Thanks or the reply,
That is the logical way to do it, but I am getting an unspecified
error,
I have used this
Private Sub CommandButton8_Click()
ListBox2.Clear
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
ListBox6.Clear
ListBox7.Clear
End Sub

and this
Sub ClearListBox()
'On Error Resume Next
With UserForm1
..ListBox2.Clear
..ListBox3.Clear
..ListBox4.Clear
..ListBox5.Clear
..ListBox6.Clear
..ListBox7.Clear
End With

both codes result in Unspecified errors

If I use the error code then nothing happens at all....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top