Filter in all excel tabs based on criteria

I have an excel file with multiple tabs(sheets), I need to filter all tabs by current month data will start from A9 in each tab

and filter all values with non zero in column J (data starts from row 9). in the attached file Shift Total should be filtered by non zeros

Please note : tab names are dynamic.
2015-Jul.xlsb
2015-Jul.xlsx
NirvanalearnerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try

Sub Macro1()

For Each sht In ActiveWorkbook.Worksheets
    sht.Activate
    Set myRange = Range(Range("A9"), Range("J9").End(xlDown))
    myRange.AutoFilter Field:=1, Criteria1:=xlFilterThisMonth, Operator:=xlFilterDynamic
    myRange.AutoFilter Field:=10, Criteria1:="<>0"
Next
End Sub

Open in new window

Regards
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
@Rgonzo1971
Please don't get me wrong but if I am not wrong, declaring all the variables used in the code is a good practice.
Also you don't need to activate each sheet to apply filter, that will make the code slow and if you wish to activate each sheet, you mush also include a line Application.ScreenUpdating = False in the beginning of the code and Application.ScreenUpdating = True before the code ends.

The proper code should be like this.....
Sub FilterAllSheets()
Dim Sh As Worksheet
Dim myRange As Range
For Each Sh In ActiveWorkbook.Worksheets
    Set myRange = Sh.Range("A9", Sh.Range("J9").End(xlDown))
    With myRange
        .AutoFilter Field:=1, Criteria1:=xlFilterThisMonth, Operator:=xlFilterDynamic
        .AutoFilter Field:=10, Criteria1:="<>0"
    End With
Next
MsgBox "Done.", vbInformation
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rgonzo1971Commented:
@sktneer
All those things are possible, but first most askers just want a functioning solution, second I consider my first solution only a possibility if the asker want some refinement or directions on why I used something then I can answer afterwards
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
@Rgonzo1971
To me OP's question is pretty straightforward. And also I assume that its not always the case if the OP has good VBA skill and competent enough to change the code as per the actual requirement.
But that was only my point of view and I talked about some basics, you may not agree with this.
ProfessorJimJamMicrosoft Excel ExpertCommented:
this code, is dynamic in case if your last column is not J

Sub TTTT()

j = Worksheets.Count
For k = 1 To j
With Worksheets(k)
.Range("A9").Resize(Cells.Find(What:="*", SearchOrder:=xlRows, _
      SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
      Cells.Find(What:="*", SearchOrder:=xlByColumns, _
      SearchDirection:=xlPrevious, LookIn:=xlValues).Column).AutoFilter Field:=10, Criteria1:="<>0", _
        Operator:=xlAnd
    .Range("A9").Resize(Cells.Find(What:="*", SearchOrder:=xlRows, _
      SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
      Cells.Find(What:="*", SearchOrder:=xlByColumns, _
      SearchDirection:=xlPrevious, LookIn:=xlValues).Column).AutoFilter Field:=1, Criteria1:= _
        xlFilterThisMonth, Operator:=xlFilterDynamic
End With
Next k

    
End Sub

Open in new window

NirvanalearnerAuthor Commented:
I would have loved to give more points. but thanks a ton for the solution.. you are the one who make this world a lovable place..saves massive time..thanks again
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Uday!
Glad we could help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.