Wookiee
Active Member
- Joined
- Nov 27, 2012
- Messages
- 440
- Office Version
- 365
- 2019
- Platform
- Windows
Hello, my fellow Excel enthusiasts. I have a problem which I know is not insurmountable, but whose solution I have so far failed to find online anywhere. After spending almost an hour searching blogs and forums, I felt it best to pose my question here.
I have a macro which opens an existing file, then deletes unnecessary columns and leaves me with a 3-column table. The problem I have is that my usual code for autofilter/delete hangs up when I attempt to delete the visible rows after having set the filter for my criteria. I know this has something to do with the fact that my data's in a table, but I haven't figured out a way so far to allow me to delete those useless rows of data. I'm sure I could construct a loop to do it, but I try to avoid loops in my macros whenever possible.
Ironically, the code I got by using the macro recorder doesn't even work. Here is the pertinent code (VBA throws the error on the last line; informing me that I'm attempting to shift cells on a table in my worksheet).
Can anyone offer a solution?
Thanks!
I have a macro which opens an existing file, then deletes unnecessary columns and leaves me with a 3-column table. The problem I have is that my usual code for autofilter/delete hangs up when I attempt to delete the visible rows after having set the filter for my criteria. I know this has something to do with the fact that my data's in a table, but I haven't figured out a way so far to allow me to delete those useless rows of data. I'm sure I could construct a loop to do it, but I try to avoid loops in my macros whenever possible.
Ironically, the code I got by using the macro recorder doesn't even work. Here is the pertinent code (VBA throws the error on the last line; informing me that I'm attempting to shift cells on a table in my worksheet).
Code:
ActiveSheet.ListObjects("tblClerks").Range.AutoFilter Field:=3, Criteria1:="<>Vendor"
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Can anyone offer a solution?
Thanks!