Ok, I figured it out.
I don't know why, but removing the Shift
parameter from the Delete
method worked. It did initially display a prompt to ask me to confirm the deletion, but setting DisplayAlerts
to false
before the delete works (and of course back to true
afterwards).
Sub deleteTableRow()
Dim row As Range ' The table row to delete
On Error Resume Next
With Selection.Cells(1)
Set row = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange)
On Error GoTo 0
If row Is Nothing Then
MsgBox "Please select a valid table cell.", vbCritical
Else
Application.DisplayAlerts = False
row.Delete
Application.DisplayAlerts = True
End If
End With
End Sub