0

I know how to delete multiple rows when it's not a Table object (i.e. just the entire row)

Sub Delete()
Rows(“1:3”).EntireRow.Delete
End Sub

I also know how to delete a single row from a Table object:

Sub Delete()
ActiveSheet.ListObjects("Table1").ListRows(1).Delete
End Sub

But I'm not sure how to delete multiple rows from a Table object. Specifically, I will always need to delete rows from 1 to some n that the user specifies from Table1 .

I currently have it as a for-loop in my macro to achieve this, but this is painfully slow when n is high. So if there's a simple adaptation of the above, that would be great?

  • https://stackoverflow.com/questions/34387929/looping-through-rows-in-a-listobject-to-delete-them-is-very-slow – Tim Williams Mar 22 '23 at 16:36
  • Don't think the delete function let's you delete more than one row a time so you would have to create your own sub to do it like so: Sub DeleteRows(ListObj, rowsToDelete) x = Application.Min(rowsToDelete) For i = Application.Min(rowsToDelete) To Application.Max(rowsToDelete) ListObj.ListRows(x).Delete Next i End Sub Sub Macro1() Range("H8:I9").Select ' Delete rows 3 & 4 DeleteRows Selection.ListObject, Array(3, 4) End Sub (sorry question got closed off by the time i finished testing it out) – Badrul Mar 22 '23 at 16:47

0 Answers0