**更新!感谢所有对我的问题做出贡献的人。问题解决了!
我的循环不起作用,但我的if语句在活动电子表格上起作用。我已经绕着它玩了几个小时了,我似乎不能弄清楚。循环将继续循环访问同一活动工作表,而不是循环访问工作簿中的所有电子表格。
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
此VBA应该循环遍历所有图纸。如果列N的总和大于20,000,则列G将过滤出“0:”。接下来,它应该循环通过下一个电子表格.如果列N不大于20000,那么我希望它不做任何事情就移动到下一个电子表格。
我尝试了每个循环,我得到了与for循环相同的结果。
3条答案
按热度按时间jvidinwx1#
试试这个
eblbsuwk2#
一次过滤所有工作表
bfrts1fy3#
在每个循环处添加一行以激活相应的工作表:
希望有帮助,再见