Vba 宏 excel:如果单元格等于 FALSE,如何隐藏行

Vba macro excel: How to hide rows if cell equal FALSE

我有一个项目需要 Excel 在用户选择活动 sheet 上的特定选项后隐藏单独 sheet(在同一工作簿中)的行。宏链接到一个按钮,当点击的行将隐藏在单独的 sheet 上,整个过程在后台发生。如果用户想要检查带有隐藏行的 table,他们需要导航到单独的 sheet 以查看结果。

图片说明: http://postimg.org/image/ek6981vg1/

Worksheets("Input- Select Pens") --> active sheet 哪里有按钮

Worksheets("Input- Pen") --> 分开 sheet 隐藏行

我尝试了几种方法,但都没有用: 方法一:

Sub selectPens()
Dim c As Range
Application.EnableEvents = False
On Error Resume Next
For Each c In Range("E6:E35")
   If c.Value = "FALSE" Then
        Worksheets("Input- Pen").c.EntireRow.Hidden = True
    ElseIf c.Value = "TRUE" Then
        Worksheets("Input- Pen").c.EntireRow.Hidden = False
   End If
 Next c
 On Error GoTo 0
 Application.EnableEvents = True
 End Sub

方法二:

Sub selectPens()
Dim i As Long
Set wselect = Sheet11
With wselect
For i = 6 To 35
    If ActiveSheet.Cells(i, 5).Value = "FALSE" Then

        .Range("i:i").EntireRow.Hidden = True
        ' .Rows(i).EntireRow.Hidden = True
    ElseIf ActiveSheet.Cells(i, 5).Value = "TRUE" Then
        ' .Rows(i).EntireRow.Hidden = False
        .Range("i:i").EntireRow.Hidden = False
    End If
Next i
End With

End Sub

如有任何帮助,我将不胜感激。

非常感谢!

Sub selectPens()

    Dim i As Long,  wsselect
    Set wselect = Sheet11

    For i = 6 To 35
        'EDIT
        wselect.Rows(i).Hidden = (ActiveSheet.Cells(i, 5).Value = False)        
    Next i

End Sub