I have a userform that displays data from a sheet, in my code I want to delete the enitre row that is selected in the listbox. I found code from another it but id didn't work code is below.

Private Sub acceptbutton_Click()

    Dim LastRow As Long, ws As Worksheet
    
    Set ws = Sheets("MattBrownData")

    LastRow = ws.Range("U" & Rows.Count).End(xlUp).Row + 1

    ws.Range("U" & LastRow).Value = mattbrownoverview.datetxt
    ws.Range("V" & LastRow).Value = mattbrownoverview.urntxt
    ws.Range("W" & LastRow).Value = mattbrownoverview.firsttxt
    ws.Range("X" & LastRow).Value = mattbrownoverview.lasttxt
    ws.Range("Y" & LastRow).Value = mattbrownoverview.returntxt
    ws.Range("Z" & LastRow).Value = mattbrownoverview.hourstxt
    ws.Range("AB" & LastRow).Value = ThisWorkbook.Sheets("Administrator Panel").Range("O5")
    ws.Range("AC" & LastRow).Value = mattbrownoverview.commentstxt
    ws.Range("AD" & LastRow).Value = mattbrownoverview.personaltxt
    ws.Range("AG" & LastRow).Value = "1"
    

'Sheets("leaveform").Visible = True
'Sheets("leaveform").PrintOut
'Sheets("leaveform").Visible = False

     
    Dim OutApp As Object
    Dim OutMail As Object
    
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
        
    With OutMail
        .To = "email"
        '.cc = "email"
        .bcc = mattbrownoverview.personaltxt
        .Subject = "Leave Request Accepted | URN: " & mattbrownoverview.urntxt
        .body = mattbrownleaveform.datelabel & mattbrownleaveform.DTPicker1 & vbCrLf & mattbrownleaveform.namelabel & mattbrownleaveform.nametxt & vbCrLf & ThisWorkbook.Sheets("leaveform").Range("G13") & ThisWorkbook.Sheets("Data").Range("AG1") & vbCrLf & mattbrownleaveform.departmentlabel & mattbrownleaveform.Departmenttxt & vbCrLf & vbCrLf & mattbrownleaveform.leavetypelabel & mattbrownleaveform.leavetypecombo & mattbrownleaveform.othertxt & vbCrLf & mattbrownleaveform.firstlabel & mattbrownleaveform.DTPicker2 & vbCrLf & mattbrownleaveform.lastlabel & mattbrownleaveform.DTPicker3 & vbCrLf & mattbrownleaveform.returnlabel & mattbrownleaveform.DTPicker4 & vbCrLf & mattbrownleaveform.hourslabel & mattbrownleaveform.hourstxt & vbCrLf & vbCrLf & mattbrownleaveform.commentslabel & mattbrownleaveform.commentstxt
        .votingoptions = "Leave Request Accepted;Leave Request Declined"
        .display
        .Send
    End With
        
    Set OutMail = Nothing
    Set OutApp = Nothing


Dim indexi As Long
indexi = mattbrownrequestlist.ListIndex + 1
If indexi <> -1 Then
Sheet19.Rows(indexi).EntireRow.Delete
ListBox1.ListFillRange = "U1003:AD1002"
End If


Range("U1002:AG2002").Select
    Range("AG1002").Activate
    ActiveWorkbook.Worksheets("MattBrownData").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("MattBrownData").Sort.SortFields.Add Key:=Range( _
        "U1003:U2002"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("MattBrownData").Sort
        .SetRange Range("U1002:AG2002")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

    Unload Me
           
End Sub