Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Filtering multiple sheets

Can any one tell me why the code below only seems to run on the active
worksheet? also is there any way to unfilter all 4 worksheets without
making them active?


Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With


Module4.Enable_Events
Application.ScreenUpdating = True


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Filtering multiple sheets

You are missing all the periods associated with the WITH Add a period in
front of the word RANGE like below. Without the period you are only
accessing the activesheet.

Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
.Range("A1:K2"), Unique:=False
.Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
.Range("A1:K2"), Unique:=False
.Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
.Range("A1:K2"), Unique:=False
.Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
.Range("A1:K2"), Unique:=False
.Range("C6").Select
End With


Module4.Enable_Events
Application.ScreenUpdating = True


End Sub



"Patrick C. Simonds" wrote:

Can any one tell me why the code below only seems to run on the active
worksheet? also is there any way to unfilter all 4 worksheets without
making them active?


Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With


Module4.Enable_Events
Application.ScreenUpdating = True


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Filtering multiple sheets

When the code is in a General module (not behind a worksheet), then those
unqualifed ranges will refer to the active sheet.

With ActiveWorkbook.Worksheets("Relief Board")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=.Range("A1:K2"), Unique:=False
'you can only select a range on the activesheet
'so you have to add the .select or remove the .range("C6").select line
.Select
.Range("C6").Select
End With

The dots in front of all the range's mean that they belong to the object in the
previous with statement (Worksheets("Relief board") in this portion).

Without the dots (.range("a1:k2), too!), these unqualified ranges will point
back at the activesheet.

"Patrick C. Simonds" wrote:

Can any one tell me why the code below only seems to run on the active
worksheet? also is there any way to unfilter all 4 worksheets without
making them active?

Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

Module4.Enable_Events
Application.ScreenUpdating = True

End Sub


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Filtering multiple sheets

Thanks.

The other half of the question was, is there any way to unfilter all 4
worksheets (show all data) with out making each worksheet active?


"Dave Peterson" wrote in message
...
When the code is in a General module (not behind a worksheet), then those
unqualifed ranges will refer to the active sheet.

With ActiveWorkbook.Worksheets("Relief Board")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=.Range("A1:K2"), Unique:=False
'you can only select a range on the activesheet
'so you have to add the .select or remove the .range("C6").select
line
.Select
.Range("C6").Select
End With

The dots in front of all the range's mean that they belong to the object
in the
previous with statement (Worksheets("Relief board") in this portion).

Without the dots (.range("a1:k2), too!), these unqualified ranges will
point
back at the activesheet.

"Patrick C. Simonds" wrote:

Can any one tell me why the code below only seems to run on the active
worksheet? also is there any way to unfilter all 4 worksheets without
making them active?

Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

Module4.Enable_Events
Application.ScreenUpdating = True

End Sub


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Filtering multiple sheets

Figured it out


"Patrick C. Simonds" wrote in message
...
Thanks.

The other half of the question was, is there any way to unfilter all 4
worksheets (show all data) with out making each worksheet active?


"Dave Peterson" wrote in message
...
When the code is in a General module (not behind a worksheet), then those
unqualifed ranges will refer to the active sheet.

With ActiveWorkbook.Worksheets("Relief Board")
.Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=.Range("A1:K2"), Unique:=False
'you can only select a range on the activesheet
'so you have to add the .select or remove the .range("C6").select
line
.Select
.Range("C6").Select
End With

The dots in front of all the range's mean that they belong to the object
in the
previous with statement (Worksheets("Relief board") in this portion).

Without the dots (.range("a1:k2), too!), these unqualified ranges will
point
back at the activesheet.

"Patrick C. Simonds" wrote:

Can any one tell me why the code below only seems to run on the active
worksheet? also is there any way to unfilter all 4 worksheets without
making them active?

Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

Module4.Enable_Events
Application.ScreenUpdating = True

End Sub


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Filtering multiple sheets

You say 'With', then fail to fully reference the range, snippet of your code
below showing the full stop in front of the range references.


With ActiveWorkbook.Worksheets("Relief Board")
.Range("A6:K3000").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:= .Range("A1:K2"), Unique:=False
.Range("C6").Select
End With


--

Regards,
Nigel




"Patrick C. Simonds" wrote in message
...
Can any one tell me why the code below only seems to run on the active
worksheet? also is there any way to unfilter all 4 worksheets without
making them active?


Sub FilterData()
'
'
'
Application.ScreenUpdating = False

Module4.Disable_Events

With ActiveWorkbook.Worksheets("Relief Board")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Fixed Route Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Paratransit Operators")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With

With ActiveWorkbook.Worksheets("Dispatchers, PSC's and CSR's")
Range("A6:K3000").AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Range("A1:K2"), Unique:=False
Range("C6").Select
End With


Module4.Enable_Events
Application.ScreenUpdating = True


End Sub


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
Filtering of data in a master excel sheet from multiple sheets Khawajaanwar Excel Discussion (Misc queries) 3 January 25th 10 05:22 PM
Filtering protected sheets (again). StargateFanFromWork[_4_] Excel Programming 1 April 5th 07 04:56 PM
Filtering for multiple sheets JVDM Excel Discussion (Misc queries) 1 October 11th 05 10:50 PM
Macro For Filtering on Multiple Sheets Rick[_13_] Excel Programming 0 August 25th 03 02:40 AM
Filtering on Formulas (makes messy sheets) Progster Excel Programming 1 July 15th 03 04:21 PM


All times are GMT +1. The time now is 03:42 PM.

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

About Us

"It's about Microsoft Excel"