Clear a Filter in VBA

KHaag

New Member
Joined
Jun 1, 2018
Messages
21
I have a Macro that opens another file and unfilters the file before using it.

I'm using the code: ActiveSheet.ShowAllData
ActiveSheet.Range($A$6:$AF$172).AutoFilter Field:=26, Critical:="="

If the file happens to not be filtered, I get a debug error. I did get this code by recording the Macro.

Is there code to simple tell Excel to clear any and all filters?

Thank you,
Kim
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,023
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
   ActiveSheet.AutoFilterMode = False
 

KHaag

New Member
Joined
Jun 1, 2018
Messages
21
Hello Fluff,
This worked!!! And it was SO simple!!!
Thank you so much :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,023
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,827
Messages
5,544,550
Members
410,619
Latest member
gregor222
Top