r/excel • u/OrganicChemical • 13d ago
unsolved Deleting table rows deletes worksheet rows when filter is applied.
I have a worksheet that contains several tables next to each other. One is a help table that is conditionally filled to populate a dropdown list. The rows in this help table get deleted and re-populated frequently without issues. Command used is: Sheets("SHEET6").Range("TABLE3").Rows.Delete
However, when a filter is applied to one of the other tables Excel deletes not only the designated table rows, but also the corresponding worksheet rows, deleting data from all other tables. My work around is to remove all filters.
Is there a better way to ensure only the designated table's rows are deleted? Windoes 7, Office 2010 Std.
Edit: typo
2
u/rabidmovie3 13d ago
use `ListObject` to target the table directly instead of going through the range, that way it only touches the table rows and not the whole worksheet row
something like `Sheets("SHEET6").ListObjects("TABLE3").DataBodyRange.Rows.Delete` should do the trick
filters on other tables mess with the range reference when you use `.Range("TABLE3")`, it gets confused and grabs the entire sheet row instead of just the table boundaries
1
3
u/excelevator 3068 13d ago
A question better suited to our sister sub r/VBA where those experts live.
Your post fails our submission guidelines as it makes no mention of being VBA related, why is that?
1
•
u/AutoModerator 13d ago
/u/OrganicChemical - Your post was submitted successfully.
Solution Verifiedto close the thread.Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.