Hide Column Based on Value in Cells

DSS_DSS

New Member
Joined
Oct 17, 2013
Messages
1
Dear All,

I am attempting to program a macro that will automatically hide column "G" when cell F9 is "FALSE." I wrote the code below, but it does not work. Do you have any suggestions?

Private Sub Worksheet_Change(ByVal Target As Range)​
If Target.Address = "$F$9" Then​
Columns("G").EntireColumn.Hidden = (Target.Value = "FALSE")​
End If​
End Sub​
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

sweeneytime

Board Regular
Joined
Aug 23, 2010
Messages
183
I tested the below and it works for me, make sure it is saved in the correct sheet in the vba editor. Let me know how it goes.


HTML:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    
    If Range("F9") = "False" Then
        Columns("G:G").EntireColumn.Hidden = True
    End If

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,682
Messages
5,524,257
Members
409,566
Latest member
MickB

This Week's Hot Topics

Top