Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Apply macro to all worksheets

Hi Everyone
This macro works ok on the open worksheet. I would like to filter all worksheets
in the workbook
Sub Filter()
For Each wks In Selection
Selection.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 4, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 4, 30)
Next wks
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Apply macro to all worksheets

On Jun 22, 8:28*am, "Cimjet" wrote:
Hi Everyone
This macro works ok on the open worksheet. I would like to filter all worksheets
in the workbook
Sub Filter()
* * * * For Each wks In Selection
* * Selection.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 4, 1),
Operator:=xlAnd, _
* * * * Criteria2:="<" & DateSerial(2011, 4, 30)
* * * * * * * * * *Next wks
* * *End Sub


for each wks in worksheets
ws.autofilter
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Apply macro to all worksheets

Hi Don
See my other post ("Custom Filter")
"Don Guillett" wrote in message
...
On Jun 22, 8:28 am, "Cimjet" wrote:
Hi Everyone
This macro works ok on the open worksheet. I would like to filter all
worksheets
in the workbook
Sub Filter()
For Each wks In Selection
Selection.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 4, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 4, 30)
Next wks
End Sub


for each wks in worksheets
ws.autofilter

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Apply macro to all worksheets

Hi Don
For each wks in worksheets ---that works ok but
ws.autofilter ----that gave me an error. Run time error 448---Named argument
not found.

here is the macro..
Sub Filter()
For Each ws In Worksheets
ws.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 3, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
Next ws
End Sub
Regards
Cimjet
"Don Guillett" wrote in message
...
On Jun 22, 8:28 am, "Cimjet" wrote:
Hi Everyone
This macro works ok on the open worksheet. I would like to filter all
worksheets
in the workbook
Sub Filter()
For Each wks In Selection
Selection.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 4, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 4, 30)
Next wks
End Sub


for each wks in worksheets
ws.autofilter

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Apply macro to all worksheets

Hi Cimjet,

Am Wed, 22 Jun 2011 12:38:57 -0400 schrieb Cimjet:

Sub Filter()
For Each ws In Worksheets
ws.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 3, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
Next ws
End Sub


you have to activate each worksheet or you have to write "With ws"
Try this:
For Each ws In Worksheets
With ws.UsedRange
.AutoFilter , Field:=2, _
Criteria1:="" & DateSerial(2011, 3, 1), _
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
End With
Next ws


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Apply macro to all worksheets

Hi Claus
It's not working properly. I get this message..plus it's not filtering all
sheets, one is left out.
Run time error 1004---AutoFilter method of range class failed.
Claus, see my other post "Custom Filter" I'm getting the same error. but it's
filtering all sheets.
Any help would be appreciated.
Cimjet


"Claus Busch" wrote in message
...
Hi Cimjet,

Am Wed, 22 Jun 2011 12:38:57 -0400 schrieb Cimjet:

Sub Filter()
For Each ws In Worksheets
ws.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 3, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
Next ws
End Sub


you have to activate each worksheet or you have to write "With ws"
Try this:
For Each ws In Worksheets
With ws.UsedRange
.AutoFilter , Field:=2, _
Criteria1:="" & DateSerial(2011, 3, 1), _
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
End With
Next ws


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Apply macro to all worksheets

Claus
Correction it's not filtering all sheets, it's leaving one out just like yours
"Cimjet" wrote in message
...
Hi Claus
It's not working properly. I get this message..plus it's not filtering all
sheets, one is left out.
Run time error 1004---AutoFilter method of range class failed.
Claus, see my other post "Custom Filter" I'm getting the same error. but it's
filtering all sheets.
Any help would be appreciated.
Cimjet


"Claus Busch" wrote in message
...
Hi Cimjet,

Am Wed, 22 Jun 2011 12:38:57 -0400 schrieb Cimjet:

Sub Filter()
For Each ws In Worksheets
ws.AutoFilter Field:=2, Criteria1:="" & DateSerial(2011, 3, 1),
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
Next ws
End Sub


you have to activate each worksheet or you have to write "With ws"
Try this:
For Each ws In Worksheets
With ws.UsedRange
.AutoFilter , Field:=2, _
Criteria1:="" & DateSerial(2011, 3, 1), _
Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2011, 3, 30)
End With
Next ws


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2



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
Apply Macro to all worksheets in a workbook except one Carrie_Loos via OfficeKB.com Excel Discussion (Misc queries) 5 January 15th 09 10:03 PM
automatically apply a macro to all worksheets minrufeng Excel Discussion (Misc queries) 5 February 21st 06 09:34 PM
Apply Macro on Multiple Worksheets in a Workbook Agnes Excel Programming 0 September 24th 04 01:39 AM
Apply Macro on Multiple Worksheets in a Workbook Agnes Excel Programming 1 September 23rd 04 06:56 PM
Apply Macro on Multiple Worksheets in a Workbook Agnes Excel Programming 1 September 23rd 04 02:20 AM


All times are GMT +1. The time now is 04:28 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"