+ Reply to Thread
Results 1 to 3 of 3

use of Worksheet_Change(ByVal Target As Range)

  1. #1
    Isaac
    Guest

    use of Worksheet_Change(ByVal Target As Range)

    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.



  2. #2
    Gonzo
    Guest

    Re: use of Worksheet_Change(ByVal Target As Range)

    Does "Drop Down 16" exist and what error do you get (you just say it's
    not working)?

    Isaac schreef:

    > 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.



  3. #3
    Dave Peterson
    Guest

    Re: use of Worksheet_Change(ByVal Target As Range)

    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



    Isaac wrote:
    >
    > 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.


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1