Hide/Unhide different set of Rows based on various cell values

  • Hi everyone,


    I need to Hide/Unhide a set of rows in excel based on what cell value is selected.
    I have a set of data of approximately 3000 rows. I want all these rows (2:3000) hidden
    When I write A in Cell A1 the excel should unhide rows from 2:100
    Similarly when I select B in Cell A1 excel should unhide rows from 101:200
    and so on.
    Kindly assist.
    Thanks.
    [email protected]

  • Re: Hide/Unhide different set of Rows based on various cell values


    Put this in the workbook open event


    Code
    Option Explicit
    
    
    
    
    Private Sub Workbook_Open()
    Rows("2:3000").Hidden = True
    End Sub


    Put this in the worksheet change event for the particular worksheet


    Code
    Option Explicit
    
    
    
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Target = Range("A1")
    If Target.Value = "A" Then Rows("2:100").Hidden = False
    If Target.Value = "B" Then Rows("101:200").Hidden = False
    End Sub


    Add additional if statements as needed

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!