Formula or Macro?

  • Thread starter Thread starter Penny Usher
  • Start date Start date
P

Penny Usher

I would like this statement to run when entering a number in a cell

If Cell = X then Hide Row N

Is this possible with a formula or do I need a macro? If formula, how is it
written?

Thanks

PJ
 
You need a worksheet_change event macro
right click sheet tab>view code>copy/paste this>modify to suit>save
now if you enter 3 in cell b1, column 3 (C) will hide

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$B$1" Then Exit Sub
If Target = 3 Then Columns(Target).Hidden = True
End Sub
 
Change to this to hide the column for the number in cell b1

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$B$1" Then Exit Sub
Columns(Target).Hidden = True
End Sub
 
Back
Top