espenskeie
Well-known Member
- Joined
- Mar 30, 2009
- Messages
- 636
- Office Version
- 2016
- Platform
- Windows
Hi
I have tried two different codes for removing items from listbox2.
It works fine when I select one of the items in the middle, but as soon as I select the last one in the list, all of the items are removed at the same time...
I cannot find what is causing this, but I have a feeling that it could be pretty obvious when I learn what it is...
Kind regards
Espen
I have tried two different codes for removing items from listbox2.
It works fine when I select one of the items in the middle, but as soon as I select the last one in the list, all of the items are removed at the same time...
Code:
If ListBoxX.ListIndex = -1 Then Exit Sub
For i = ListBoxX.ListCount - 1 To 0 Step -1
If ListBoxX.Selected(i) = True Then
Sheets("1HourHL").Range("X10").Value = Me.ListBoxX.Value
ListBoxX.RemoveItem i
End If
Next i
I cannot find what is causing this, but I have a feeling that it could be pretty obvious when I learn what it is...
Kind regards
Espen