Custom function does not work from an addin

A

agarwaldvk

I have written a custom function. It works perfectly well when the cod
is in a module sheet in the same workbook that the function is use
in.

However, when I create an AddIn file for this custom function by savin
it as an AddIn i.e with an .xla extension, e.g MyFunc.xla and then us
the function in another workbook, it always comes up with an error
Before using this function in the other workbook, I have made sure tha
with the workbook that I want to use the function in as the activ
workbook, a reference to the addin (MyFunc.xla) has been made b
checking the check box for this addin by going into Tools-Addin etc..

What am I doing wrong? Can anyone help?


Best regards


Deepak Agarwa
 
R

Ron Rosenfeld

I have written a custom function. It works perfectly well when the code
is in a module sheet in the same workbook that the function is used
in.

However, when I create an AddIn file for this custom function by saving
it as an AddIn i.e with an .xla extension, e.g MyFunc.xla and then use
the function in another workbook, it always comes up with an error.
Before using this function in the other workbook, I have made sure that
with the workbook that I want to use the function in as the active
workbook, a reference to the addin (MyFunc.xla) has been made by
checking the check box for this addin by going into Tools-Addin etc..

What am I doing wrong? Can anyone help?

What is the error?

Could there be a naming conflict?


--ron
 
3

39N95W

agarwaldvk > said:
I have written a custom function. It works perfectly well when the code
is in a module sheet in the same workbook that the function is used
in.

However, when I create an AddIn file for this custom function by saving
it as an AddIn i.e with an .xla extension, e.g MyFunc.xla and then use
the function in another workbook, it always comes up with an error.
Before using this function in the other workbook, I have made sure that
with the workbook that I want to use the function in as the active
workbook, a reference to the addin (MyFunc.xla) has been made by
checking the check box for this addin by going into Tools-Addin etc..

What am I doing wrong? Can anyone help?

My test results on your situation:

TEST_xla.xla contains a module with this function

Public Function CubeMe(num as Integer) as Long
CubeMe = num * num * num
end function

After activating the AddIn file, the function worked in several workbooks
that I opened and tested it in, e.g. in cell A1 of some workbook type in

=CubeMe(3)

OR

=CubeMe(C4) etc.


Perhaps your function in the *.xla isn't declared as Public? Might be a
scope issue.

HTH.

-gk-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top