I have a procedure that deletes all rows in a table, and I have another that adds a row. The problem is when I run DeleteAllRows and then AddRow immediately after, it doesn't work the first time. It only works on the second run.
Why is this and what is the solution?
Sub DeleteAllRows() With Range("Table1").ListObject If Not .DataBodyRange Is Nothing Then .DataBodyRange.Delete End If End With End Sub
Sub AddRow() Dim ws As Worksheet Dim tbl As ListObject Set ws = Worksheets("Sheet1") Set tbl = ws.ListObjects("Table1") tbl.ListRows.Add End Sub
Bookmarks