我想隐藏 B 列和 C 列中值为零的行。我的代码有效,但仅在活动工作表上有效。我希望它遍历工作簿中的所有工作表。任何帮助表示赞赏
Private Sub CommandButton1_Click()
Dim M As Long, LastRow As Long
Dim ws As worksheet
For Each ws In ActiveWorkbook.Worksheets
LastRow = ws.Range("E65536").End(xlUp).Row
For M = LastRow To 7 Step -1
If Range("B" & M).Value = 0 And Range("C" & M).Value = 0 Then
Range("B" & M).EntireRow.Hidden = True
End If
Next M
Next ws
End Sub