+ Reply to Thread
Results 1 to 29 of 29

Ambiguous name error

  1. #1
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Ambiguous name error

    I have two codes running that are both worksheet_change
    What do I have to do to make the name acceptable and run?

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Ambiguous name error

    You can't have two only one. You can combine them.
    Last edited by JOHN H. DAVIS; 08-14-2015 at 10:40 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    Have you tried Debug > Compile VBAProject ?

    If it still doesn't detect the error, then look for two identically named Public variables in two different modules.

    I had this yesterday - causes all sorts of weird behaviour like not being able to step into code from a Worksheet function.

    Usually 'Debug > Compile VBAProject' picks up this sort of thing, but yesterday it didn't.

  4. #4
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    How would I combine these two. Essentially they do the same thing, I'm just very new at VB.

    Please Login or Register  to view this content.
    The first one likely isn't setup properly.
    B14 down to B50 are the dropdown cells and I need the adjacent C,D, and E dependent lists to clear (again 14 to 50)

    The second code works great. J6 is my dropdown list and the dependent lists H3, L3 and L6 clear when info is changed.

    thanks

  5. #5
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    I've changed the other code and both work fine on their own.
    I can't figure out how to combine them however.

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    Something like this:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    That is most excellent. Thank you.
    I have 4 identical tabs, order, order(2), order(3), order (4)
    How do I make the code run for all of them?
    thanks

  8. #8
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    Try this:
    Please Login or Register  to view this content.
    (untested, BTW)

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Ambiguous name error

    Either copy the code to each worskheet module or use the workbook SheetChange event.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  10. #10
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    It doesn't seem to work, perhaps they should be the sheet #'s instead of 'names'?

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Ambiguous name error

    Did you try the code I posted?

    It goes in the ThisWorkbook module.

  12. #12
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    Sorry, slow connection today. Storm went through.
    How do I get to ThisWorkbook module?
    When I select the sheet under microsoftexcelobjects in the window the code is still there for my original sheet.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Ambiguous name error

    Double click ThisWorkbook in the Project Explorer.

  14. #14
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    Sorry, slow connection today
    Yeah, me too. My code is supposed to go in the Workbook_SheetChange event also. Tsk, writing on the fly.

  15. #15
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    Ah, that helps.
    Unfortunately not working though.
    edit:
    Will try that cyiangou.

  16. #16
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    unfortunately my firs (order) tab still works but not on the others

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Ambiguous name error

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  18. #18
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    I will. It will take a few minutes to update my dropbox file with my currently ludicrously slow speed.

  19. #19
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    I will try to do this at a later time. My upload speed is very slow.
    Thanks for the help so far. I'll process it further. Probably something I'm doing wrong.

  20. #20
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    In my code, please check the line
    Please Login or Register  to view this content.
    and make sure the exact names of your tabs are in each field, eg. order(3) has no space, but order (4) does? I copied these directly from your post.

  21. #21
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    Still working on the upload of my file. Speeds as low as 0.3 kb/s
    I was trying the different ideas out but now even my separate codes are not working anymore. Not sure what I did.

  22. #22
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    https://www.dropbox.com/s/26nenkmsce...ftge.xlsm?dl=0

    My file.
    I inputted this code into each of the four sheets. It's the closest I got to it working (not on the dropbox one)
    Please Login or Register  to view this content.
    The first sheet "order" works totally fine. But with the other three, only the first half runs.

  23. #23
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    Ok, I've now tested this code in your file. Comment out your Worksheet_Change subs in the 4 sheets. Add this to your ThisWorkbook module:
    Please Login or Register  to view this content.
    I made a few changes, verify that my assumptions are correct:
    • I assumed that in the range reference 'Range("H3:J3,L3:N3,L6:O3")', the L6:O3 part was a mistake and was meant to read L3:O3 ?
    • I also assumed that in the 2nd IF block, that you intend that when an entry is made in column B, that you want the 3 columns to the right to be cleared, but ONLY FOR THAT ROW, and not ALL the detail rows.

  24. #24
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    Thanks very much. It seems to be working great now. Good catch on the L6:O3 it was actually supposed to be L6:O6.
    Yes you are correct on just the 3 columns clearing and not the entire row.
    This has been a hurdle for m.e It's great to be moving on to new ones.

  25. #25
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Ambiguous name error

    cyiangou

    Just curious, why are you using Target.Worksheet.Name?

    If you want to get the name of the sheet the change has been made on use Sh.Name.

  26. #26
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    @Norie

    I always felt that the sh object was superfluous. I guess it's just me proving once again that it's unnecessary.

  27. #27
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Ambiguous name error

    cyiangou

    Kind of confused by that post, but it doesn't matter as it looks like we've sorted the OP's problem.

  28. #28
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Ambiguous name error

    It's just that I wonder why they provided 2 parameters when one already includes the other?

    The other reason I used Target is that intellisense works with an explicit declaration; not so with an 'As Object' variable.

    We also know that a generic Object is slightly slower while vba resolves its underlying type, but so is using 'too many dots', as in Target.Worksheet.Name, as that also must be resolved. So not really sure which is the best way.

  29. #29
    Forum Contributor
    Join Date
    06-10-2008
    Location
    SW Ontario, Canada
    MS-Off Ver
    Excel 365
    Posts
    154

    Re: Ambiguous name error

    I really appreciated the input from everyone. I'm just beginning my adventure in VB and while I still have no clue what I'm doing I feel like I did learn from this.
    thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. error msg in VBA, ambiguous name that locks Excel
    By jwright650 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2022, 08:07 PM
  2. VBA Compile Error: Ambiguous name detected
    By kieranoduill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 05:31 PM
  3. [SOLVED] 2 VBA codes under the same event - Ambiguous name error
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2013, 05:28 AM
  4. how to avoid Ambiguous Name error?
    By rbs123 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-21-2013, 06:39 AM
  5. [SOLVED] compile error ambiguous name detected!?
    By Margate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2013, 08:49 PM
  6. Compile Error: Ambiguous Name Worksheet_Change
    By vtsoldier2010 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-16-2012, 09:18 AM
  7. Ambiguous name detected error
    By jpxexcelforum in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-07-2011, 06:04 PM
  8. Ambiguous error
    By famdamly in forum Excel General
    Replies: 1
    Last Post: 02-27-2006, 05:10 AM

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