Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 295
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro using autofilter Lorna B Excel Discussion (Misc queries) 5 May 25th 07 06:54 PM
Can I use a macro to autofilter in excel priceyindevon Excel Worksheet Functions 0 October 14th 06 06:47 PM
autofilter macro flow23 Excel Discussion (Misc queries) 1 April 18th 06 03:00 PM
Keep autofilter after macro is run gmr7 Excel Worksheet Functions 2 July 5th 05 01:16 PM
Autofilter Macro Help RonB Excel Discussion (Misc queries) 1 December 30th 04 01:34 AM


All times are GMT +1. The time now is 09:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"