Hidden Row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am working on an excel document where when a specific cell says no a row
will hide. This is the code I am using:
Private Sub Worksheet_Calculate()
If Worksheets("Interview").Range("A28").Value = "No" Then
Worksheets("Interview").Range("E29").EntireRow.Hidden = True
If Worksheets("Interview").Range("A28").Value = "Yes" Then
Worksheets("Interview").Range("E29").EntireRow.Hidden = False

End Sub

It will run fine when I place a no in the cell and go to the visual basic
and hit play, but I want it to run automatically. I wan the row to hide once
the cell says no, so you don't have to go to the visual basic editor and hit
play. Any suggestions?

thank you,

Dan
 
Try this

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$28" Then
With Target
If .Value = "No" Then
Me.Range("E29").EntireRow.Hidden = True
ElseIf .Value = "Yes" Then
Me.Range("E29").EntireRow.Hidden = False
End If
End With
End If

ws_exit:
Application.EnableEvents = True
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