Hi,
I'm going round in circles here! How do I remove an item from a list box, when it is selected in the list and a "remove" button is clicked on?
Many Thanks,
Jon
Hi,
I'm going round in circles here! How do I remove an item from a list box, when it is selected in the list and a "remove" button is clicked on?
Many Thanks,
Jon
Re: Removing an Item from a list box
nojy,
This can present some challenges especially if you allow multiple items to be selected. Due to lack of information I'm going to assume that the list box is on a userform or it's an ActiveX type listbox on a worksheet.
If you allow multiple items to be selected you must remove the last selected item first and loop to the beginning.
For intCount = ListBoxNameHere.ListCount - 1 to 0 step -1
if ListBoxNameHere.Selected(intCount) then ListBoxNameHere.RemoveItem(intCount)
next intCount
See if this works for you.
Re: Removing an Item from a list box
To remove an item from a listbox, you can 1) remove the item(s) from the actual list on the worksheet, as prescribed by the Input Range that you created, or 2) modify the Input Range field such that the cell reference(s) that you wish to remove are deleted. Not sure what you mean by a "remove" button. Am I missing something, friend?
Bubbis Thedog
Re: Removing an Item from a list box
Thanks guys for the swift replies i've used bits from all answers and got a perfect working remove button in my Form to remove items from a list.
Thanks again!
Jon
Re: Removing an Item from a list box
Why not post up the final code, so we can all see what you used... ?
Don’t have an account yet? Register yourself now and be a part of our community!