abhay_547
06-02-2010, 08:06 AM
Hi All,
I have a Textbox and a Listbox on a excel userform and I have a two Command buttons one is "Add" and another one is "Remove". I have written the following code in my excel userform background. Basically what I am trying to do is when I type something in my text box and click on the "Add" button then it should add text entered by me in textbox to listbox as a new item and when I select the some of the items in my listbox and click on "Remove" button then it should remove all those selected items from my listbox. I have set my listbox property as below.
Linestyle = 1 and MultiSelect = 1.
Following is the code which I have :
Private Sub Add_Click()
ListBox1.AddItem TextBox1.Value
End Sub
Private Sub Remove_Click()
ListBox1.Selected Clear
End Sub
Above code works fine when I "Add" something using command button "Add" but when I try to "Remove" some of the items from the multiple items reflecting in listbox1 (which were added by me using textbox) it doesn't work. Please help.
Thanks a lot for your help in advance.
I have a Textbox and a Listbox on a excel userform and I have a two Command buttons one is "Add" and another one is "Remove". I have written the following code in my excel userform background. Basically what I am trying to do is when I type something in my text box and click on the "Add" button then it should add text entered by me in textbox to listbox as a new item and when I select the some of the items in my listbox and click on "Remove" button then it should remove all those selected items from my listbox. I have set my listbox property as below.
Linestyle = 1 and MultiSelect = 1.
Following is the code which I have :
Private Sub Add_Click()
ListBox1.AddItem TextBox1.Value
End Sub
Private Sub Remove_Click()
ListBox1.Selected Clear
End Sub
Above code works fine when I "Add" something using command button "Add" but when I try to "Remove" some of the items from the multiple items reflecting in listbox1 (which were added by me using textbox) it doesn't work. Please help.
Thanks a lot for your help in advance.