Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Apply Macro to all worksheets in a workbook except one | Excel Discussion (Misc queries) | |||
automatically apply a macro to all worksheets | Excel Discussion (Misc queries) | |||
Apply Macro on Multiple Worksheets in a Workbook | Excel Programming | |||
Apply Macro on Multiple Worksheets in a Workbook | Excel Programming | |||
Apply Macro on Multiple Worksheets in a Workbook | Excel Programming |