ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Loop through userform (https://www.excelbanter.com/excel-discussion-misc-queries/179379-loop-through-userform.html)

Paul Morgan

Loop through userform
 
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


Rick Rothstein \(MVP - VB\)[_197_]

Loop through userform
 
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


"Paul Morgan" wrote in message
...
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



Paul Morgan

Loop through userform
 
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....



All times are GMT +1. The time now is 09:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com