I have the following code which deletes a row from a table ("EPAtable"). It deletes the row which contains the value selected in the "EPAlist" listbox which is on a userform.
Code
dim lrow as long
dim str as string
On Error Resume Next
lrow = Application.WorksheetFunction.Match(EPAlist.value, Range("EPATable").Columns(1), 0)
On error GoTo 0
If lrow > 0 Then
Sheet12.Range("EPATable").Rows([lrow]).EntireRow.Delete
End If
End If
With EPAList
str = .RowSource
.RowSource = vbNullString
.Rowsource = str
End With
End Sub
Display More
This code works only sometimes. Sometimes when I run the macro, nothing happens, I get an error or excel crashes.
I am just learning VBA, so perhaps there is a better way to accomplish what it is I am trying to accomplish?