My if statement is working on the active spreadsheet.
The loop continues to loop through the same active sheet instead of looping through all the spreadsheets within a workbook.
Sub WorksheetLoop()
Dim WS_Count As Integer
Dim I As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 1 To WS_Count
'For Each Ws In Workbooks
If WorksheetFunction.Sum(Range("N:N")) > 20000 Then
Range("A:P").AutoFilter Field:=7, Criteria1:="<> 0
End If
Next I
End Sub
This VBA code is supposed to loop through all the sheets. If the sum of column N is greater than 20,000, then column G will filter out "0:. Next, It should loop through the next spreadsheet. If column N is not greater than 20000, then I want it to move on to the next spreadsheet without doing anything.
I tried a for each loop and I got the same results as the for loop.