Autofilter or Unfilter data

Tested in Excel 365 (16.8730.2046) 64-bit

 
 
  1. Public Sub AutoFilterOrUnfilter()
  2.     If ActiveSheet.AutoFilterMode Then ' if autofilter is on
  3.        If ActiveSheet.FilterMode = True Then 'if the data is filtered
  4.            ActiveSheet.ShowAllData   ' remove the filter to show all data
  5.        End If
  6.     Else
  7.         Cells.Select ' select all sheet
  8.        Selection.AutoFilter ' add autofilter
  9.    End If
  10. End Sub

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.