Hide colum

  • Thread starter Thread starter rodw
  • Start date Start date
R

rodw

I want to hide colums based on a cells value

so say if a1 = yes i want to hide colums b to f

and if a1 is no then i want to hide g to j

Is thi possibl
 
Hi rodw

You can do this with the change event in the worksheet module

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
If LCase(Target.Value) = "yes" Then
Columns("A:IV").Hidden = False
Columns("B:F").Hidden = True
End If
If LCase(Target.Value) = "no" Then
Columns("A:IV").Hidden = False
Columns("G:J").Hidden = True
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top