dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,392
- Office Version
- 365
- 2016
- Platform
- Windows
I have a button that deletes a row at a time but when it gets down to nothing left, as in, nothing in the last row, what do I need to add to this code to make it stop displaying an error of "no cells found" when it is trying to delete the last row and it has nothing in it. How do I stop that error appearing?
The code is:
The code is:
Code:
Dim ans As Long
With ActiveSheet.ListObjects("tblCosting").DataBodyRange
ans = .Rows.Count
If ans > 1 Then .Rows(ans).Delete
If ans = 1 Then .Rows(1).Cells.SpecialCells(xlCellTypeConstants).ClearContents
End With
Last edited: