Avatar of jtolksdo
jtolksdo
 asked on

conditional hiding of rows and/or columns

Hi,

I'd like to hide rows and/or columns based on some cell contents, after these contents are entered. I fill the cell contents with check-boxes by adding a cell-link from the check-box to a cell.
If the box is checked, the cell shows the value true.


If I want to do this based on one expression I use the VBA Code as follos:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.ScreenUpdating = False
     ' Dim R As Range
     ' Set R = Application.Intersect (Target, Range("B7:B7"))
     ' If R Is Nothing Then Exit Sub
    With ActiveSheet
        For Each Cell In Range("C7")
            If Cell.Value = "explicit" Then
                Cell.EntireColumn("F").Hidden = True
                Cell.EntireColumn("E").Hidden = True
                Cell.EntireColumn("G").Hidden = False
            Else
                Cell.EntireColumn("G").Hidden = True
                Cell.EntireColumn("E").Hidden = False
                Cell.EntireColumn("F").Hidden = False
            End If
            Next
    End With
    Application.ScreenUpdating = True
End Sub
---

Now I'd like to add something like this:
    With ActiveSheet
        For Each Cell In Range("C11")
            If Cell.Value = "true" Then
                Cell.EntireColumn("I").Hidden = True
            Else
                Cell.EntireColumn("I").Hidden = False
            End If
----
Unfortunately I don't know how (my last code might be totally wrong).
Please advise.
Visual Basic ClassicVB Script

Avatar of undefined
Last Comment
RobSampson

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
RobSampson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck