+ Reply to Thread
Results 1 to 2 of 2

Compile error: Ambigious name detected: Worksheet_Change **NEWBIE**

  1. #1
    dan
    Guest

    Compile error: Ambigious name detected: Worksheet_Change **NEWBIE**

    Hi all -
    I am getting a Compile error: Ambigious name detected: Worksheet_Change
    message when processing my code.

    >From reading various posts, I see that I can only use the

    Worksheet_Change process once.

    In my code below, how can I combine these procedures so I can make this
    work? Thanks for your help!

    '-----------------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    '-----------------------------------------------------------------
    Const WS_RANGE As String = "d5"

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    Range("c6:c24").Copy Range("c7:c25")
    Range("c6").Value = Target.Value
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    '-----------------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    '-----------------------------------------------------------------
    Const WS_RANGE As String = "q5"

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    Range("p6:p24").Copy Range("p7:p25")
    Range("p6").Value = Target.Value
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub


  2. #2
    Ardus Petus
    Guest

    Re: Compile error: Ambigious name detected: Worksheet_Change **NEWBIE**

    '-----------------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    '-----------------------------------------------------------------
    Const WS_RANGE1 As String = "d5"
    Const WS_RANGE2 As String = "q5"

    On Error GoTo ws_exit:
    Application.EnableEvents = False

    If Not Intersect(Target, Me.Range(WS_RANGE1)) Is Nothing Then
    Range("c6:c24").Copy Range("c7:c25")
    Range("c6").Value = Target.Value
    End If

    If Not Intersect(Target, Me.Range(WS_RANGE2)) Is Nothing Then
    Range("p6:p24").Copy Range("p7:p25")
    Range("p6").Value = Target.Value
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub
    '-------------------------------------------------------------

    HTH
    --
    AP

    "dan" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > Hi all -
    > I am getting a Compile error: Ambigious name detected: Worksheet_Change
    > message when processing my code.
    >
    >>From reading various posts, I see that I can only use the

    > Worksheet_Change process once.
    >
    > In my code below, how can I combine these procedures so I can make this
    > work? Thanks for your help!
    >
    > '-----------------------------------------------------------------
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > '-----------------------------------------------------------------
    > Const WS_RANGE As String = "d5"
    >
    > On Error GoTo ws_exit:
    > Application.EnableEvents = False
    > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    > Range("c6:c24").Copy Range("c7:c25")
    > Range("c6").Value = Target.Value
    > End If
    >
    > ws_exit:
    > Application.EnableEvents = True
    > End Sub
    >
    > '-----------------------------------------------------------------
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > '-----------------------------------------------------------------
    > Const WS_RANGE As String = "q5"
    >
    > On Error GoTo ws_exit:
    > Application.EnableEvents = False
    > If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    > Range("p6:p24").Copy Range("p7:p25")
    > Range("p6").Value = Target.Value
    > End If
    >
    > ws_exit:
    > Application.EnableEvents = True
    > End Sub
    >




+ 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