Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This one has to be really easy, but I can't track it down. I know how
to remove an item from a listbox using its index value, but how do I remove it by directly referring to the name of the item? Example: lbx1.RemoveItem ("DeleteThis") This line errors out as an invalid argument. Please help. Thanks, Randy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Randy,
You have to loop through the list items. If you had a CommandButton1 on your form, this sub would remove an item called "Doug": Private Sub CommandButton1_Click() Dim i As Long For i = 0 To Me.ListBox1.ListCount - 1 If Me.ListBox1.List(i) = "Doug" Then Me.ListBox1.RemoveItem (i) Exit Sub End If Next i End Sub In some situations it makes sense to clear the list, e.g., Me.ListBox1.Clear, and then repopulate the Listbox. hth, Doug "Randy" wrote in message ups.com... This one has to be really easy, but I can't track it down. I know how to remove an item from a listbox using its index value, but how do I remove it by directly referring to the name of the item? Example: lbx1.RemoveItem ("DeleteThis") This line errors out as an invalid argument. Please help. Thanks, Randy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I know how do that easily enough. It just seems like a lot of
unnecessary lines to process, but oh well. Thanks for your help. Randy |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Randy,
I agree! Doug "Randy" wrote in message oups.com... I know how do that easily enough. It just seems like a lot of unnecessary lines to process, but oh well. Thanks for your help. Randy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Double click item in Listbox to select item and close Listbox | Excel Programming | |||
listbox add item | Excel Programming | |||
remove item fr listbox (correction) | Excel Programming | |||
Add item to listbox, but only if it is not already there. | Excel Programming | |||
listbox remove Item | Excel Programming |