I have a spreadsheet with a 'userform' which has a 'listbox' which displays the data found in a worksheet (which is populated by a user via various sheets), all that is fine however I am trying to set it up so that when a user identifies a row in the userform they can select the row and then select "delete" (using a command button) and it will then delete that row of data from the worksheet.
I have some code I got from an old workbook but can't get it to work proparly.
I have attached a copy of the worksheet and userform if someone can help.
Private Sub CommandButton2_Click()
Dim Response As String
Dim strDelName As String
If .ListIndex > 0 Then
strDelName = .List(.ListIndex, 2) & " " & .List(.ListIndex, 3)
Response = MsgBox("You have selected " & strDelName & " for Deletion." _
& vbNewLine & vbNewLine & " If this is correct please select ""Yes""" _
& "and the record will be deleted.", vbYesNo + vbInformation, _
"Delete Record Information")
If Response = vbYes Then
Worksheets("Summary").Rows(.ListIndex + 1).Delete xlShiftUp
MsgBox strDelName & " has been deleted.", vbOKOnly + vbInformation, _
"Delete Record Information"
MsgBox "You have chosen not to delete " & strDelName & " from the system." _
, vbOKOnly + vbInformation, "Delete Record Information"
MsgBox Prompt:=Err.Number & " " & Err.Description, _
Buttons:=vbInformation + vbOKOnly, _