+ Reply to Thread
Results 1 to 5 of 5

#NAME? error for UDF

  1. #1
    Registered User
    Join Date
    08-01-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    10

    #NAME? error for UDF

    I have created a UDF for doing a simple calculation for my colleague. I have tested it and it works fine in my own file (.xlsm). So I copied it and pasted into a module in my colleague's file (also .xlsm) but I keep getting a #NAME? error when calculating it. It is inserted in a module that has a different name from the function itself and everything is copied exactly to his file, but I still get the problem and I don't know what the difference is. We're both running Office 2007. Can anyone tell me what I'm doing wrong?

    This is the UDF:
    Please Login or Register  to view this content.
    Last edited by OnlyTheSnake; 09-12-2012 at 04:31 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: #NAME? error for UDF

    Copied into a standard module, it works fine for me.

    I can get a #NAME? error if I create a second identical code module ... but I get Ambiguous Name detected, so that's pretty obvious.

    I get a #NAME? error if the function call in the worksheet is spelt wrong.

    I don't get a #NAME? error if I make it a Private Function or a Private Module.

    But I do get a #NAME error if I put the function in a Sheet class module.

    So, some options to look at ...


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: #NAME? error for UDF

    also if you have macros disabled ;-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: #NAME? error for UDF

    @JP: Ah, never thought of that. Started out in an existing workbook (without code) and just pasted the code in ... obviously, I could then run it. I'll be annoyed if that's the answer.

  5. #5
    Registered User
    Join Date
    08-01-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: #NAME? error for UDF

    Quote Originally Posted by JosephP View Post
    also if you have macros disabled ;-)
    Damn, it really was that simple...

    Signed the macro, trusted it on his computer and it works fine now. Thanks for the tip (and for making me kick myself).

+ 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