+ Reply to Thread
Results 1 to 8 of 8

Compile Error: Ambiguous Name Worksheet_Change

  1. #1
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Compile Error: Ambiguous Name Worksheet_Change

    Dear Forum,

    I'm having a little difficulty with a piece of code that I'm trying to write. I keep getting a compile error when I test the code from the Visual Basic window in Excel. I think the problem lies in me having the same sub twice within a single worksheet module, but I may be wrong. Also, if you guys could look at the second set of code and make suggestions for how I can improve it I would be eternally grateful. What I'm trying to accomplish with the code is I have three data validation dependent drop down lists set up on a worksheet. What I would like to do is populate an adjacent cell with data based on the choices made in all three drop down lists. The choices have to match specific criteria exactly, and work so that after the user has made their third choice the adjacent cell is populated with the data corresponding to the choices they've made. Hope this helps and thanks in advance.


    Private Sub Worksheet_Change(ByVal Target As Range)
    Set Target = Intersect(Target, Range("q2:s1048576"))
    If (Not Target Is Nothing) Then
    Target.Offset(0, 1).Value = ""
    End If

    End Sub


    Private Sub Worksheet_Change(ByVal Target As Range)

    If Range(q2).Value = "PLX" And Range(r2).Value = "Imaging_TopCall" And Range(s2).Value = "Missing From File" Then
    PrelimRisk.AddItem = "Level 1"

    ElseIf Range(q2).Value = "Document" And Range(r2).Value = "Assignment" And Range(s2).Value = "Not Needed" Then
    PrelimRisk.AddItem = "Level 2"

    ElseIf Range(q2).Value = "Document" And Range(r2).Value = "Assignment" And Range(s2).Value = "Incorrect Investor" Then
    PrelimRisk.AddItem = "Level 1"

    ElseIf Range(q2).Value = "PLX" And Range(r2).Value = "Inadequate Research" And Range(s2).Value = "Research Not Followed" Then
    PrelimRisk.AddItem = "Level 1"

    ElseIf Range(q2).Value = "Document" And Range(r2).Value = "Assignment" And Range(s2).Value = "Data Integrity Error" Then
    PrelimRisk.AddItem = "Level 1"

    End If

    End Sub

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Compile Error: Ambiguous Name Worksheet_Change

    You are right, you cannot do what you are trying to do so this is what you need:
    Please Login or Register  to view this content.

    Google Me
    Find me located here Simon Lloyd
    and what i'm about Here
    The above is NOT a link to a forum so is NOT against Rule 13

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Compile Error: Ambiguous Name Worksheet_Change

    You need some quotes around those cell addresses ...
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Compile Error: Ambiguous Name Worksheet_Change

    Lol, well spotted shg


    Google Me
    Find me located here Simon Lloyd
    and what i'm about Here
    The above is NOT a link to a forum so is NOT against Rule 13

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Compile Error: Ambiguous Name Worksheet_Change

    vtsoldier2010

    Please use Code Tags not Quote Tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Ambiguous Name Worksheet_Change

    Thanks for all your help guys will try this out now and let you know if it works.

  7. #7
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Ambiguous Name Worksheet_Change

    Hey guys I tried your suggestions and I got it to work, but now I have another problem. I'm getting a Runtime error 13 Type Mismatch. I modified the code slightly out of a necessity to expand the code to all the cells in the four columns my code is interacting with. Heres my code. The line that's in bold is the line that the compiler is higlighting as having an issue. Any help would be greatly appreciated. Thanks

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-14-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Compile Error: Ambiguous Name Worksheet_Change

    Apparently the bold didn't work, but the line that causing the error is

    Please Login or Register  to view this content.

+ 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