Excel VBA Will Not Recognise AutoFilter Is Enabled

Harry Y

New Member
Joined
Feb 3, 2020
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Excel vba will not recognise that AutoFilter is enabled. However, it works on the initial sheet which the code is run from.

Using code:
If ActiveSheet.AutoFilterMode Then
Option 1
Else
Option 2
End If

I have tried to use vba prior to the above code, to remove and re-add the autofilter on the sheet, but that made no difference (I used "ActiveSheet.Range("Table_Data[#Headers]").AutoFilter").
I have also tried using "If ActiveSheet.AutoFilterMode = True Then" & "If ActiveSheet.AutoFilterMode = False Then" and the code definitely thinks that the filters are not applied.

Has anyone had this issue and knows how to fix it?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If you're trying to interact with a listobject ("Table_Data[#Headers]") - then you can't use that logic. It doesn't apply to the filtering of listobjects (Tables).
If you want to see if there's anything filtered in the listobject, use sheet.listobject.autofilter.filtermode. This will return True if a filter is apply, False if there is not. You can then use .ShowAllData to clear the filter.
If you're trying to turn off the arrows, then you'll have to select the entire table and use the AutoFilter command.
Tables are their own objects - listobjects. They have their own properties and methods.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top