Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Autofilter from macro
Hello
I'm trying to autofilter on/off via a macro. The filters may be on or off at the time and I want to turn them on for certain criteria. The following code debugs on the .AutoFilterMode = True statement. If I leave that part out then it debugs on the Autofilter for field 1. Can someone put me straight please? Regards,Brett Sheets("FIP").Unprotect With ActiveSheet .AutoFilterMode = False End With With ActiveSheet .AutoFilterMode = True End With Range("status:app").Select ActiveWindow.ScrollColumn = Range("sec.surname") ActiveWindow.ScrollRow = Range("header.row").Value + 1 Selection.AutoFilter Field:=3 Selection.AutoFilter Field:=1, Criteria1:="ACTIVE" 'Sheets("FIP").Protect DrawingObjects:=True, Contents:=True, AllowFiltering:=True 'Sheets("FIP").EnableSelection = xlUnlockedCells |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Autofilter from macro
To turn autofilter on you need a range. Try:-
With ActiveSheet .AutoFilterMode = False End With With ActiveSheet .Range("A1").AutoFilter '<Alter to suit End With Mike "Brettjg" wrote: Hello I'm trying to autofilter on/off via a macro. The filters may be on or off at the time and I want to turn them on for certain criteria. The following code debugs on the .AutoFilterMode = True statement. If I leave that part out then it debugs on the Autofilter for field 1. Can someone put me straight please? Regards,Brett Sheets("FIP").Unprotect With ActiveSheet .AutoFilterMode = False End With With ActiveSheet .AutoFilterMode = True End With Range("status:app").Select ActiveWindow.ScrollColumn = Range("sec.surname") ActiveWindow.ScrollRow = Range("header.row").Value + 1 Selection.AutoFilter Field:=3 Selection.AutoFilter Field:=1, Criteria1:="ACTIVE" 'Sheets("FIP").Protect DrawingObjects:=True, Contents:=True, AllowFiltering:=True 'Sheets("FIP").EnableSelection = xlUnlockedCells |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Autofilter from macro
Thanks Mike, all fixed now. Cheers, Brett
"Mike H" wrote: To turn autofilter on you need a range. Try:- With ActiveSheet .AutoFilterMode = False End With With ActiveSheet .Range("A1").AutoFilter '<Alter to suit End With Mike "Brettjg" wrote: Hello I'm trying to autofilter on/off via a macro. The filters may be on or off at the time and I want to turn them on for certain criteria. The following code debugs on the .AutoFilterMode = True statement. If I leave that part out then it debugs on the Autofilter for field 1. Can someone put me straight please? Regards,Brett Sheets("FIP").Unprotect With ActiveSheet .AutoFilterMode = False End With With ActiveSheet .AutoFilterMode = True End With Range("status:app").Select ActiveWindow.ScrollColumn = Range("sec.surname") ActiveWindow.ScrollRow = Range("header.row").Value + 1 Selection.AutoFilter Field:=3 Selection.AutoFilter Field:=1, Criteria1:="ACTIVE" 'Sheets("FIP").Protect DrawingObjects:=True, Contents:=True, AllowFiltering:=True 'Sheets("FIP").EnableSelection = xlUnlockedCells |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro using autofilter | Excel Discussion (Misc queries) | |||
Can I use a macro to autofilter in excel | Excel Worksheet Functions | |||
autofilter macro | Excel Discussion (Misc queries) | |||
Keep autofilter after macro is run | Excel Worksheet Functions | |||
Autofilter Macro Help | Excel Discussion (Misc queries) |