So basically, I have a program in Excel VBA where it shows a listbox with all the users/people and I have a button that deletes a user that is selected
What I need to do now is: If nothing is selected and I press the delete button It shows a message: You need to select a user then press delete
Code for the button:
Private Sub PogaDzest_Click()
If MsgBox("Do you want to delete selected user?", vbYesNo + vbQuestion) = vbYes Then
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(i, 1) = ListBox1.List(ListBox1.ListIndex) Then
Rows(i).Select
Selection.Delete
End If
Next i
ListBox1.List(ListBox1.ListIndex) = Delete
End If
End Sub
Bookmarks