Check if Filter is applied

christianbiker

Active Member
Joined
Feb 3, 2006
Messages
365
Hi all,

I am wondering if there is a way for a macro to check if any filters have been applied before moving to the next step in a macro. Prior to my macro being fully executed, I need to warn the user that they haven't applied any filters from the column headers because if none are applied, the copy/paste function will contain too much information on another sheet where the data will be pasted.

Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How about
VBA Code:
      If ActiveSheet.FilterMode = False Then
         MsgBox "blah blah"
         Exit Sub
      End If
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0
.. the copy/paste function will contain too much information ..

Just to be sure that you are getting what you want, note that Fluff's code does do what your thread title says, but it does not ensure that any rows are hidden by the auto filter.

For example, in the image below you can see that column B has a filter applied but you can also see that no rows are hidden (The filter is set to show numbers >1 and all rows meet that criteria)

1618313591737.png



If you want to test that something is actually hidden, you could try

VBA Code:
With ActiveSheet.AutoFilter.Range
  If .Columns(1).SpecialCells(xlVisible).Cells.Count = .Rows.Count Then
    MsgBox "Nothing hidden"
    Exit Sub
  End If
End With
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,995
Members
448,539
Latest member
alex78

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