0

I am trying to delete an entire row from a Table (ListObject), but I have issues adressing the Row. Following code works prefect when the table is not filtered:

Sub loeschen()

If errorhandling Then On Error GoTo fehlerbehandlung

    ActiveCell.ListObject.ListRows(ActiveCell.Row - ActiveCell.ListObject.HeaderRowRange.Row).Delete

Exit Sub
fehlerbehandlung:
fehlermeldung

End Sub

Filtering is done by user in Excel, not VBA. Is there a direct way to delete a row or do I have to unfilter it? And if that's the case, how do I filter it again the same way (the user shouldn't notice anything, I'll apply Application.ScreenUpdatingif necessary.

2 Answers 2

1

If it is already filtered, you can try this:

ActiveSheet.ListObjects([Table_Name]).DataBodyRange.EntireRow.Delete

Sign up to request clarification or add additional context in comments.

Comments

0

I figured it out.

You have to call the row this way

ActiveCell.ListObject.Range.EntireRow(ActiveCell.Row - ActiveCell.ListObject.HeaderRowRange.Row + 1).Delete

Even if filtered, the right row will be deleted. (Same thing for .Select)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.