• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hide Columns on Value Change

Gregg Wolin

Member
All I want is to have several columns (H thru K) either be hidden or visible based on the value of cell G5. I have seen countless examples but none seem to fit my needs.

P.S. I also ONLY want the macro to trigger when the specific cell value is changed (rather than any change on the worksheet).

Thanks in advance for your help!
 

Attachments

  • Inputs_BigTable.xlsm
    364.9 KB · Views: 2
I was able to accomplish the column hiding I desired with the code below.
________
Code:
Sub Worksheet_Change(ByVal Target As Range)

Dim c As Range
 
 Application.ScreenUpdating = False
 
 Columns("h:k").EntireColumn.Hidden = False
 
  If Not Application.Intersect(Range("g5"), Range(Target.Address)) Is Nothing Then
    End If

  For Each c In Rows("1:1").Cells
    If c.Value = "x" Then c.EntireColumn.Hidden = Not c.EntireColumn.Hidden
      Next c

 Application.ScreenUpdating = True

End Sub
 
Back
Top