+ Reply to Thread
Results 1 to 7 of 7

Module name messing up UDF?

  1. #1
    Registered User
    Join Date
    12-23-2010
    Location
    usa
    MS-Off Ver
    Excel 2010
    Posts
    66

    Module name messing up UDF?

    Hello,

    One of my custom VBA functions keeps on giving me a #Name as the result even though I can't find anything wrong with the code. After doing some testing, it turns out that the reason it's giving me a #Name is because of the module name, which is the same as the function name.

    Is this not allowed in Excel? Why can't I name the module the same as the function.

    thanks

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Module name messing up UDF?

    No, it's not permitted - causes an uncaught error.

    For function Foo, why not call your module modFoo ?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Module name messing up UDF?

    Hi anon,

    I'd expect that you need to name all things differently in code. Why does it seem strange to need to name a UDF different than a Sub or Module?

    Perhaps http://www.excelforum.com/excel-gene...-function.html will help?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Module name messing up UDF?

    that's the way it is the recommendation is
    "You can also have problems running your macros if the procedures have the same name as a module in the workbook. To avoid that, start your module names with "mod", such as modUpdate, and don't use those names for any macros."
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    12-23-2010
    Location
    usa
    MS-Off Ver
    Excel 2010
    Posts
    66

    Re: Module name messing up UDF?

    Doesn't seem strange but I'm just trying to keep things organized. I've never coded before (except trying to learn VBA) so still trying to get the hang of things. I guess it would make sense that 2 things need different names - just didn't know a module was a 'thing'.

    Thanks for the responses.

  6. #6
    Registered User
    Join Date
    12-23-2010
    Location
    usa
    MS-Off Ver
    Excel 2010
    Posts
    66

    Re: Module name messing up UDF?

    Also good, idea. I';ll start adding 'mod' in front of my modules

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Module name messing up UDF?

    It is not recommended but it is not impossible to use the same name for module and function. You must simply use =modulename.functionname() when you enter it in the cell.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

+ 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. [SOLVED] Code locks cells when inserted in sheet module but returns error in standard module
    By yoda66 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2014, 07:39 AM
  2. how to access Sheet module, normal module, Worbook module to type code
    By alibaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2009, 07:51 AM
  3. "1" messing up prime no. module
    By 173 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-28-2008, 03:47 AM
  4. DDE Module Messing up Other Code
    By Lil Pun in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-26-2006, 01:25 PM
  5. Replies: 1
    Last Post: 04-10-2005, 07:07 PM

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