Clearing a listbox
I have a listbox loaded from addItem.
The listbox is on a userform. There comes a moment in the program when I want the listbox to unload what is in the listbox and reuse the same listbox so I can add different items. Is there a fast way to do that, without unloading the form? Or is the a way to quickly clear a listbox contents and repopulate it with other items? -- wbnTravis, from Oklahoma |
Clearing a listbox
Listbox1.Clear
Corey..... "wbntravis" wrote in message ... I have a listbox loaded from addItem. The listbox is on a userform. There comes a moment in the program when I want the listbox to unload what is in the listbox and reuse the same listbox so I can add different items. Is there a fast way to do that, without unloading the form? Or is the a way to quickly clear a listbox contents and repopulate it with other items? -- wbnTravis, from Oklahoma |
Clearing a listbox
From VB Help:
expression.RemoveItem(Index, Count) expression An expression that returns a ControlFormat object. Index Required Long. The number of the first item to be removed. Valid values are from 1 to the number of items in the list (returned by the ListCount property). Count Optional Variant. The number of items to be removed, starting at item Index. If this argument is omitted, one item is removed. If Index + Count exceeds the number of items in the list, all items from Index through the end of the list are removed without an error. -- Ian -- "wbntravis" wrote in message ... I have a listbox loaded from addItem. The listbox is on a userform. There comes a moment in the program when I want the listbox to unload what is in the listbox and reuse the same listbox so I can add different items. Is there a fast way to do that, without unloading the form? Or is the a way to quickly clear a listbox contents and repopulate it with other items? -- wbnTravis, from Oklahoma |
Clearing a listbox
Thanks IanC and Corey.... each gave me a different perspective
and I will use both where needed or where I want to experiment . : ) -- wbnTravis, from Oklahoma "IanC" wrote: From VB Help: expression.RemoveItem(Index, Count) expression An expression that returns a ControlFormat object. Index Required Long. The number of the first item to be removed. Valid values are from 1 to the number of items in the list (returned by the ListCount property). Count Optional Variant. The number of items to be removed, starting at item Index. If this argument is omitted, one item is removed. If Index + Count exceeds the number of items in the list, all items from Index through the end of the list are removed without an error. -- Ian -- "wbntravis" wrote in message ... I have a listbox loaded from addItem. The listbox is on a userform. There comes a moment in the program when I want the listbox to unload what is in the listbox and reuse the same listbox so I can add different items. Is there a fast way to do that, without unloading the form? Or is the a way to quickly clear a listbox contents and repopulate it with other items? -- wbnTravis, from Oklahoma |
All times are GMT +1. The time now is 07:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com