Excel VBA to Remove Filters

Its a one liner

When creating macros that work with filters it is a good idea to remove filters at the beginning of the macro code. Here is how you do that.

Place this line of code at the top of your code

If Sheet1.AutoFilterMode Then Sheet1.AutoFilterMode = False

This removes filters from Sheet1.

Sheet1 is the sheet code name you see in the Project Explorer window on the right of the VBA screen. See image below.

This is not the tab name. In the image above the tab name is Test and the code name is Sheet1.

If you wanted to remove filters from the active sheet you can use

If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False

 

Please note: I reserve the right to delete comments that are offensive or off-topic.