VBA Code: Hiding Specific Columns & Rows Based on a Cell Value

  • Hi All,


    I have been using the following code to hide a column range based on a specific word I pick from a list in cell A2:


    Code
    Private Sub Worksheet_Change(ByVal Target As Range)    If Range("A2").Value = "Boilermaker" Then
            Columns("G:I").EntireColumn.Hidden = True
        Else
            Columns("G:I").EntireColumn.Hidden = False
        End If
    End Sub



    I would now like to expand on this by doing the following:


    1) Hiding multiple ranges of Columns based on a specific word I pick from a list in cell A2
    2) Hiding multiple ranges of Rows based on a specific word I pick from a list in cell A2


    An example would be:


    If cell A2 = Boilermaker, Columns G:I & S:Z are hidden as well as Rows 4:12 hidden.



    Any help on this would be really appreciated as I have been reading forums all day trying to find a solution to this.


    Thank you in advance,


    Mark

Participate now!

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