简体   繁体   中英

Using VBA to hide rows in Excel if a Value returns 0

I'm trying to create an automated proposal document, and when a certain value returns 0 in my spreadsheet, I want to hide a bunch of extraneous rows/graphics that are in those rows to reduce clutter and make a clean pdf to send out.

Private Sub Worksheet_Change(ByVal Target As Range)

    If .Range("F15").Value = "0" Then
        Rows("7:25").EntireRow.Hidden = True
    ElseIf Range("f15").Value Then
      Rows("7:25").EntireRow.Hidden = False
    End If

End Sub

Where should I go from here? If f15 returns as a value greater than 0, I wish for the rows to be shown.

try this, holp it works

Private Sub Worksheet_Change(ByVal Target As Range)

    If .Range("F15").Value = "0" Then
        Rows("7:25").EntireRow.Hidden = True
    Else
        Rows("7:25").EntireRow.Hidden = False
    End If

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM