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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
48,141
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,141
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,068
Messages
5,545,795
Members
410,708
Latest member
SanTrapGamer
Top