0
votes

I am trying to create a macro that will create a table and then remove the filter in the header row. To clarify, I want the filter itself eradicated, utterly removed from the table. Looking on other threads, it is difficult to discern whether people simply want their filters to say "Select all" or whether they want the filters themselves removed.. I want the filters themselves gone.

Any help would be appreciated! I am not the greatest with VBA and can't seem to find anyone on Google with similar ambitions using Excel.

4
if you know how to create a macro you will know that doing it aint that hard, add your efforts, sho the community that you have done you r homeworkMuhammad Omer Aslam

4 Answers

1
votes

This should toggle the filter on/off in a table. So, run it once, it turns the filter off, run it again to turn the filter on.

Sheets("Sheetname").ListObjects("TableName").Range.AutoFilter
1
votes

The variant I like most is the following:

Sub ResetFilters()
    On Error Resume Next
    ActiveSheet.ShowAllData
End Sub
0
votes

To turn off a filter simply use

Cells.AutoFilter

or

Sheets("Sheetname").Cells.AutoFilter
0
votes

I find that the ListObjects.Range.AutoFilter does not work when the vba code is triggered by a button, since pressing the button again would toggle the filter back on. In that case you can use:

Sheets("Sheetname").ListObjects("TableName").ShowAutoFilterDropDown = False