Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Excel autofiltermode = false not turning off autofilter

Have used activesheet.autofiltermode = false and

dim Myworksheet as worksheet
Myworksheet.autofiltermode = false

Neither removed autofilter I've use Myworksheet.ShowAllData beforehand as well. Using Office 2013 Professional Plus

like image 515
ghostracer34 Avatar asked Jul 21 '14 11:07

ghostracer34


2 Answers

For a table you need different syntax:

activesheet.listobjects(1).Autofilter.showalldata

to clear the filter, or:

activesheet.listobjects(1).ShowAutoFilter = False

if you don't want the dropdowns visible at all.

like image 59
Rory Avatar answered Nov 09 '22 09:11

Rory


This finally helped me figure out how to ensure that an Excel table's AutoFilter is on and showing all data. My final code is this:

If ActiveSheet.ListObjects(1).ShowAutoFilter Then
   ActiveSheet.ListObjects(1).AutoFilter.ShowAllData
Else
   ActiveSheet.ListObjects(1).ShowAutoFilter = True
End If
like image 6
M Dattoli Avatar answered Nov 09 '22 10:11

M Dattoli