none
Add-in and marco confict RRS feed

  • Question

  • In short, I have identical functions in add-in and macro, only differentiate by name. When running both, the function in macro always return blank cell. What I can I do to make sure that the macro works?

    Full story.

    I have collected a few tools (custom functions) that assist my work. So I put it in an Add-in so it could work without the macro-enabled file. But it turn out that I have to send it to many users to use the file. So add-in have to be install at all the computers AND the functions have to be edit to target the add-in in the machine using it if the the file is send from one user to another. That's far more than I can ask my users to perform. So I go back to put all of the code in the Add-in into a module and change the name of the function so I know when I call a function, I know which is it. The exact procedures was to open the add-in, select all, copy, create a module in file, paste all code, save file. However, my functions in macro all return blank. What I can I do to make sure that the macro works?

    Tuesday, April 3, 2018 7:40 AM

Answers

  • Finally, I found it. Because I change only the name at the top of the function, it doesn't work. Because all of them are recursive, the function's name inside did not change, hence it doesn't work. There is no conflict here.
    • Proposed as answer by Terry Xu - MSFT Wednesday, April 4, 2018 5:47 AM
    • Marked as answer by NguyenVu1991 Wednesday, April 4, 2018 10:09 AM
    Tuesday, April 3, 2018 11:06 AM

All replies

  • Hi,

    Sorry, if I misunderstand your question.

    You can add a prefix to your macro and make it differentiated from add-in function.
    For example, suppose there are two VBA macro,
      one "macro_A" is in "Module1" and
      the other "macro_A" is in "Module2".

    And you can code like "call Module1.macro_A" or "call Module2.macro_A".
    Regards,

    Ashidacchi -- http://hokusosha.com/

    Tuesday, April 3, 2018 8:12 AM
  • Ok, initially I have 1 function: CusFun in an Add-in1

    I copy all code in Add-in1 into module in Excel file, save file 1.xlsm

    I open 1.xlsm to work, now I have 2 functions CusFun 

    I changed the name (and only the name) of the functions in macro in module1 in 1.xlsm as CusFun_Port

    Now I have 2 UDF: CusFun and CusFun_Port when I work

    But CusFun_Port (all of them) always return blank while CusFun work normally.

    Hope that's clearer.

    Tuesday, April 3, 2018 8:28 AM
  • Finally, I found it. Because I change only the name at the top of the function, it doesn't work. Because all of them are recursive, the function's name inside did not change, hence it doesn't work. There is no conflict here.
    • Proposed as answer by Terry Xu - MSFT Wednesday, April 4, 2018 5:47 AM
    • Marked as answer by NguyenVu1991 Wednesday, April 4, 2018 10:09 AM
    Tuesday, April 3, 2018 11:06 AM
  • Congratulations!!
    Please mark your last post as answer and close this thread.

    Ashidacchi -- http://hokusosha.com/

    Tuesday, April 3, 2018 11:47 PM
  • Hi NguyenVu1991,

    I'm glad to hear that you have solved the issue. I would suggest you mark helpful reply as answer to close this thread.

    If you have other issue, please feel free to post threads to let us know.

    Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 4, 2018 5:47 AM