I'm trying to run a macro that replaces data in a table in Excel, when the data might initially be filtered.
The code should remove the filter first, then run the rest of the code.
I tried the "Autofilter" command, but then the normal filter option on the table's range weren't visible, and I had to manually create the filter option again (not a big deal to me, but other people use this file).
Is there a way to clear the filter WITHOUT removing filters from the table?
For a Table, you can simply use the
ShowAllData
method of itsAutofilter
object:Note this won't error even if there is no filter currently applied.
I am finding that the "...ClearAllData" method fails.
Sneaky - not hugely elegant solution - that works by field (so cumbersome if you need to do the whole table), but easy if you just have one field (e.g. field 2 in my example) is to use the wildcard:
Or
Hi Guys use this "Worksheets("Sheet1").ListObjects(1).Range.AutoFilter = False" and please note if already filter applied it will remove filter on the other hand if filter not applied before it will apply the filter.