troubleshooting Question

conditional hiding of rows and/or columns

Avatar of jtolksdo
jtolksdo asked on
Visual Basic ClassicVB Script
1 Comment1 Solution1981 ViewsLast Modified:

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
                Cell.EntireColumn("G").Hidden = True
                Cell.EntireColumn("E").Hidden = False
                Cell.EntireColumn("F").Hidden = False
            End If
    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
                Cell.EntireColumn("I").Hidden = False
            End If
Unfortunately I don't know how (my last code might be totally wrong).
Please advise.
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros