Hello everyone,
This error has been driving me crazy recently, hopefully someone has the knowledge in order to get past this error.
I am creating a Protected user form for an invoice and keep getting this error whenever I delete a table row. The macro is ran by selecting a row, pressing a button, and the cell row selected inside the table is deleted. The thing is, this error doesn't happen if I clear the worksheet of Conditional Formatting, it only happens if I introduce this specific formula:
=AND(COUNTIF(Category,$J14)>0,COUNTIFS($E$14:$E$17,$E14,$J$14:$J$17,$J14)>1)
and applied to a table. Category contains a list of "Expenses" that I want to find duplicate lines, and it will highlight yellow. I also have some validation rules to mark cells that don't meet specific criteria, such as account number is beyond 10 chars, and if I keep that in, the delete table row macro runs fine.
But, whenever I run this macro to delete a table row:
Sub DeleteRow()
Sheet1.Unprotect Password:="Password!"
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
Sheet1.Protect Password:="Password!"
End Sub
I get this error.
Run-time error '-2147417848 (80010108)'
Method 'Delete' of object 'Range' failed.
I've created a new workbook, thinking it may be a corrupted excel file, but I still get this error message.
Any thoughts?
Bookmarks