none
Adding a UDF to VBA code RRS feed

  • Question

  • Hi there!

    I am trying to add a UDF I created to VBA code, and I am getting the error that my sub or function is not defined. When I try to go to the References window and add the VBA Project containing this UDF, I am getting the error: "Name conflicts with existing module, project, or object library." How can I fix this?

    Thanks!

    Friday, August 18, 2017 4:07 PM

All replies

  • ekistner,
    re:  "add a udf"

    I think you mean "Call a function"
    When a UDF is located in a sheet module, the UDF is Private to that module.
    So, you must specify the module name (sheet code name) when calling it.

    With a function called "rapport" in a worksheet module, with the worksheet name of "Post Toasties" and a sheet code name of "Sheet1" then your code to call  the function could look like...
    Dim X As Variant
    X = Sheet1.rapport

    '---
    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)


    • Edited by James Cone Friday, August 18, 2017 10:03 PM
    Friday, August 18, 2017 9:48 PM
  • Hi ekistner,

    ->When I try to go to the References window and add the VBA Project containing this UDF, I am getting the error: "Name conflicts with existing module, project, or object library." How can I fix this?

    What is the VBA Project? Do you attempt to add a reference to a project or object library whose file name (without an extension) is the same as the name of one of the current project's modules? If so, you have to change the module name or the name of the file that could not be added. Please refer to below link for more Information.

    https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/name-conflicts-with-existing-module-project-or-object-library?f=255&MSPPError=-2147217396

    Best Regards,

    Terry

    Monday, August 21, 2017 5:47 AM