hide code does not hide

W

Wanna Learn

Hello this is my code - it does not work.
plain english - if cell B28 = 3 YR Agreement then unhide row 32 , if B28 =
1YR Agreement the unhide row 33 . I've been trying for the past 2 hours and I
do not see what's wrong. Please help and thanks
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B28").Address Then
If Target = "3 YR r Agreement" Then
Row("32").Hidden = False
If Target.Address = Range("B28") = "1 YR Agreement" Then Rows("33").Hidden =
False
End If


End Sub
 
M

Mike H

Maybe

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B28").Address Then
If Target.Value = "3 YR Agreement" Then
Rows(32).Hidden = False
ElseIf Target.Value = "1 YR Agreement" Then
Rows(33).Hidden = False
End If
End If
End Sub

Mike
 
J

Jim Thomlinson

Try this...

Private Sub Worksheet_Change(ByVal Target As Range)
with target
If .Address <> "$B$28" then exit sub
If .value= "3 YR r Agreement" Then
Rows(32).Hidden = False
Rows(33).hidden = true
ElseIf .value = "1 YR Agreement" Then
Rows(32).Hidden = true
Rows(33).hidden = false
end if
end with
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

Top