MicroMouse
New Member
- Joined
- Jul 10, 2015
- Messages
- 5
Hi All,
I am sure this is fundamental but I just don't understand why. I have a userform with a combobox and a listbox. I can add items to the listbox no problem but I wanted to be able to delete from the listbox. If I assign the following macro to a button then it works fine. However, when I assign it to the listbox_click event I get runtime error 1004.
Private Sub CommandButton1_Click()
Dim Item As String
Dim myRange As Range
Sheet1.Activate
Item = UserForm1.ListBox1.Value
Set myRange = Range("A1", Range("A65535").End(xlUp))
myRange.Find(Item, LookIn:=xlValues, Lookat:=xlWhole).Select
Selection.Delete Shift:=xlUp
UserForm1.ListBox1.RowSource = Range("A1", Range("A65535").End(xlUp)).Address
End Sub
Any thoughts?
I am sure this is fundamental but I just don't understand why. I have a userform with a combobox and a listbox. I can add items to the listbox no problem but I wanted to be able to delete from the listbox. If I assign the following macro to a button then it works fine. However, when I assign it to the listbox_click event I get runtime error 1004.
Private Sub CommandButton1_Click()
Dim Item As String
Dim myRange As Range
Sheet1.Activate
Item = UserForm1.ListBox1.Value
Set myRange = Range("A1", Range("A65535").End(xlUp))
myRange.Find(Item, LookIn:=xlValues, Lookat:=xlWhole).Select
Selection.Delete Shift:=xlUp
UserForm1.ListBox1.RowSource = Range("A1", Range("A65535").End(xlUp)).Address
End Sub
Any thoughts?