Apply macro to all worksheets
Claus
It's stoping at " .Range("B5").AutoFilter" and same error.
Run time error 1004---AutoFilter method of range class failed.
"Claus Busch" wrote in message
...
Hi Cimjet,
Am Wed, 22 Jun 2011 13:43:48 -0400 schrieb Cimjet:
I'm still getting the same error. I place the proper dates in F1 and G1
Sub Filter()
For Each wsh In Worksheets
With wsh
If Not .FilterMode Then .Range("B5").AutoFilter
.Range("B5").AutoFilter , Field:=2, Criteria1:="" & Range("F1").Value2,
_
Operator:=xlAnd, Criteria2:="<" & Range("G1").Value2
End With
Next
End Sub
here everything works fine. But I have to start the macro from the sheet
in which the date is placed or I have to reference it with sheetname.
Where did your code stop? Write in first line of module:
Option Explicit
Then you have to declare wsh as worksheet, but you see where your code
stops.
Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
|