Results 1 to 8 of 8

Thread: How to make multiple, non adjacent cells hidden based on cell value code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    How to make multiple, non adjacent cells hidden based on cell value code

    I have a spread sheet that I want to hide multiple rows, some of them are not adjacent, and I am basically new to coding in excel. I want several rows to hide based on the value of B2, and when B2 changes, I want some of those rows to show, and others to hide, all variable on the value of B2. I have been banging my head on the wall trying to figure this out, even though I know it is probably basic coding.

    I want the following rows hidden for each value in B2:

    ACSA - 24, 25, 35, 36, 57, 58, 60, all other rows not hidden
    CSA - 57, 58, 60, all other rows not hidden
    ASA - 24, 25, 30, 31, 35, 36, 50, 57, 58, 59, 60, all other rows not hidden
    ACA - 24, 25, 30, 31, 35, 36, 50, 59, 60, all other rows not hidden
    SASA - 24, 25, 30, 31, 35, 36, 50, 57, 58, 59, 60, all other rows not hidden
    Please Select Role Code - all rows not hidden

    This is what I have so far:

    Private Sub Worksheet_Change(ByVal Target As Range)
    ActiveSheet.Activate
    
    If Not Application.Intersect(Range("B2"), Range(Target.Address)) Is Nothing Then
    Select Case Target.Value
    
    Case Is = "ACSA": Rows("35:36").EntireRow.Hidden = True
    Case Is = "CSA": Rows("35:36").EntireRow.Hidden = False
    Case Is = "ASA": Rows("35:36").EntireRow.Hidden = True
    Case Is = "ACA": Rows("35:36").EntireRow.Hidden = True
    Case Is = "SASA": Rows("35:36").EntireRow.Hidden = False
    Case Is = "Please Select Role Code": Rows("35:36").EntireRow.Hidden = False
    
    
    
    
    End Select
    
    
    End If
    
    
    
    
    If Not Application.Intersect(Range("D38"), Range(Target.Address)) Is Nothing Then
    Select Case Target.Value
    
    Case Is = "Select Answer": Rows("39:47").EntireRow.Hidden = False
    Case Is = "Yes": Rows("39:47").EntireRow.Hidden = True
    Case Is = "No": Rows("39:47").EntireRow.Hidden = False
    Case Is = "NA": Rows("39:47").EntireRow.Hidden = True
    
    
    
    End Select
    
    End If
    
    
    
    End Sub


    I would really appreciate it! I am so lost at this point
    Last edited by Paul_Hossler; 02-16-2018 at 08:41 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •