use of Worksheet_Change(ByVal Target As Range)

  • Thread starter Thread starter Isaac
  • Start date Start date
I

Isaac

Dear friends the following code of hoja2 hides a combined picture (drop down
3), when j3 is different from 1, and works perfectly, but when I want to
hide another combined picture (drop drown 16) does not work. help please

FUNCTIONAL

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("j3")) Is Nothing Then Exit Sub
Me.DropDowns("Drop Down 3").Visible = CBool(Target.Value = 1)
End Sub

IT DOES NOT WORK

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("j3")) Is Nothing Then Exit Sub
Me.DropDowns("Drop Down 3").Visible = CBool(Target.Value = 1)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("BI2")) Is Nothing Then Exit Sub
Me.DropDowns("Drop Down 16").Visible = CBool(Target.Value = 1)
End Sub

Only works in first drop down3 the second no longer, how I can correct this.
 
Does "Drop Down 16" exist and what error do you get (you just say it's
not working)?

Isaac schreef:
 
You're checking to see if you changed J3 first. If you didn't change J3, then
you leave the sub. So your code never gets a chance to check BI2.

Maybe something like:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub

If Not Intersect(Target, Me.Range("j3")) Is Nothing Then
Me.DropDowns("Drop Down 3").Visible = CBool(Target.Value = 1)
End If

If Not Intersect(Target, Me.Range("BI2")) Is Nothing Then
Me.DropDowns("Drop Down 16").Visible = CBool(Target.Value = 1)
End If

End Sub
 
Back
Top