ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filter Problem (https://www.excelbanter.com/excel-programming/360697-filter-problem.html)

GregR

Filter Problem
 
I have this code where I am trying to filter each sheet in the workbook
on column "I" for 2006, except the first sheet. I am not quite there.
Need help. TIA

Sub Filter2006()
Dim sh As Worksheet

With ActiveWorkbook
For Each sh In Worksheets

If sh.Name = "IS Time Q1_06" Then

Else

Range("A1:L1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=9, Criteria1:="2006"

End If

Next sh

End With

End Sub

Greg


excelent

Filter Problem
 
try:

Sub Filter2006()

Dim sh As Worksheet

With ActiveWorkbook
For Each sh In Worksheets

If sh.Name < "IS Time Q1_06" Then

Range("A1:L1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=9, Criteria1:="2006"

End If

Next sh

End With

End Sub
-----------------------------------------------------


"GregR" skrev:

I have this code where I am trying to filter each sheet in the workbook
on column "I" for 2006, except the first sheet. I am not quite there.
Need help. TIA

Sub Filter2006()
Dim sh As Worksheet

With ActiveWorkbook
For Each sh In Worksheets

If sh.Name = "IS Time Q1_06" Then

Else

Range("A1:L1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=9, Criteria1:="2006"

End If

Next sh

End With

End Sub

Greg



GregR

Filter Problem
 
Excellent, I thought the statement means

If sh.Name = "IS Time Q1_06" Then

"do nothing"

Else
Code "do something"

Is my thinking mistaken

Greg


excelent

Filter Problem
 
well i think its the other way round :-)


GregR

Filter Problem
 
Excellent, there is also somethig about the filter, some how each sheet
needs to be activated in the loop for the filter to be applied?????


excelent

Filter Problem
 
y ur right i just notest :-)

For Each sh In Worksheets
sh.Activate ' add this line here ****

GregR

Filter Problem
 
Added sh.Activate and still it will not filter each sheet. Not sure
what my problem is?

Greg


excelent

Filter Problem
 
try show ur kode


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com