i have an issue where deleting a selected row, deletes the row selected, but the "Total Row" merges with the table and I'm unable to do anything in the excel sheet and have to reset my progress.
I was wondering if someone can take a look at my code when deleting a table and let me know if they see anything wrong. I also attached the error message I receive before I'm unable to do anything with the spreadsheet.
Sub DeleteRow()
Dim rng As Range
On Error Resume Next
With Selection.Cells(1)
Set rng = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Please select a valid table cell.", vbCritical
Else
rng.Delete xlShiftUp
End If
End With
End Sub