Hi all,
I have a UserForm with 3 Buttons and 1 ListBox, now I want the user to be able to delete items in the ListBox by selecting them and pressing the delete key. I searched online and found the KeyDown event that I suppose can be used to achieve that. However, I cannot get it to work. Below is what I've got so far:
Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = Keys.Delete Then
With ListBox1
Dim i As Long
For i = .ListCount - 1 To 0 Step -1
If .Selected(i) Then
.RemoveItem i
End If
Next i
End With
End If
End Sub
Bookmarks