32. VBA Tips - Turn Off Autofilter
Turn Off Autofilter
Turning off autofilter using VBA is easy and quick, but you need to know how it's done.
Here's some code to toggle the autofilter on and off:
Sub ToggleAutofilter() ' check if autofilter is currently off If ActiveSheet.FilterMode = False Then ' if it's off, turn it on, and filter on "Nick" Range("d5").AutoFilter Field:=1, Criteria1:="Nick" Else ' if it's on, turn it off Range("d5").AutoFilter End If End Sub
Download sheet to practise how to Turn Off Autofilter in Excel
Training video on how to Turn Off Autofilter in Excel:
Attachment | Size |
---|---|
turn-off-autofilter.xls | 56 KB |
»
- Nick's blog
- Login or register to post comments
- 46675 reads
Autofilter (Advanced)
Just a quick piece of info...
With advanced filter in Excel while trying to find out Unique, the limitation is that the destination range should be on the same sheet as the source. However, using VBA there is no such limitation. Using VBA the source and destination ranges in Advanced filter need not be on the same sheet.