I am trying to delete a row based on listbox selection but keep returning an error.
Below is the code I am using any help would be great.
Thank you.
Private Sub cmdRemove_Click()
Dim iRow As Long
If lstBudget = 0 Then
MsgBox "No row is selected.", vbOKOnly + vbInformation, "Delete"
Exit Sub
End If
Dim i As VbMsgBoxResult
i = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "Confirmation")
If i = vbNo Then Exit Sub
iRow = Application.WorksheetFunction.Match(Me.lstBudget.List.List(Me.lstBudget.List.ListIndex, 0), _
ThisWorkbook.Sheets("Output").Range("A:A"), 0)
ThisWorkbook.Sheets("output").Rows(iRow).Delete
Call Reset
MsgBox "Selected record has been deleted.", vbOKOnly + vbInformation, "Deleted"
End Sub
Bookmarks