Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do I need to do anything special to be able to call one UDF from
another UDF in a different add-in module? For some reason, I keep getting "Compile Error: Sub or Function not defined". I have them declared as Public: Public Function MyUDF(p1,p2,...) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
That should be fine. you must have a problem with the name of the function or its definition. regards Paul On Apr 27, 11:59*pm, Prof Wonmug wrote: Do I need to do anything special to be able to call one UDF from another UDF in a different add-in module? For some reason, I keep getting "Compile Error: Sub or Function not defined". I have them declared as Public: * *Public Function MyUDF(p1,p2,...) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Wed, 28 Apr 2010 04:03:42 -0700 (PDT), Paul Robinson
wrote: Hi That should be fine. you must have a problem with the name of the function or its definition. regards Paul That's what I thought, but it doesn't work. I have several personal add-in modules. As far as I know, they are all standard code modules. Each one is a .xlam file. When I open the Project Explorer, they are listed along with the VBAPROJECT modules and they have the same little multi-colored icon as all of the other code modules. One of them contains utility functions (UDFs) that I would like to be able to call from the UDFs in the other modules. I put the following code in one of the add-in modules: Public Function a_1(n) a_1 = a_2(n) End Function Public Function a_2(n) a_2 = n * n End Function It works just fine. If I put "=a_1(5)" in a cell, I get the result "25". If I move the a_2 function to another module, I get an error message: Compile Error: Sub or function not defined just as if the function did not exist. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you talking about procedures in different modules in a single workbook,
or modules in different workbook projects. Regards, Peter T "Prof Wonmug" wrote in message ... On Wed, 28 Apr 2010 04:03:42 -0700 (PDT), Paul Robinson wrote: Hi That should be fine. you must have a problem with the name of the function or its definition. regards Paul That's what I thought, but it doesn't work. I have several personal add-in modules. As far as I know, they are all standard code modules. Each one is a .xlam file. When I open the Project Explorer, they are listed along with the VBAPROJECT modules and they have the same little multi-colored icon as all of the other code modules. One of them contains utility functions (UDFs) that I would like to be able to call from the UDFs in the other modules. I put the following code in one of the add-in modules: Public Function a_1(n) a_1 = a_2(n) End Function Public Function a_2(n) a_2 = n * n End Function It works just fine. If I put "=a_1(5)" in a cell, I get the result "25". If I move the a_2 function to another module, I get an error message: Compile Error: Sub or function not defined just as if the function did not exist. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Wed, 28 Apr 2010 16:55:35 +0100, "Peter T" <peter_t@discussions
wrote: Are you talking about procedures in different modules in a single workbook, or modules in different workbook projects. That's the key. I've been doing some more testing. I have two projects (.xlam files). Each project has 2-3 code modules. If I call a UDF in a different module in the same project, it works fine. It fails it it's in a different project. Is there a way to make all modules in all projects able to access all other modules in all other projects? Or, do I have to qualify the UDF name somehow, like Call projectname.modulename.udfname(arguments...) I would like to avoid the latter, if possible, so it will work even if I move the UDFs to different projects. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Either you need to set relevant references or use Application.Run
Regards, Peter T "Prof Wonmug" wrote in message ... On Wed, 28 Apr 2010 16:55:35 +0100, "Peter T" <peter_t@discussions wrote: Are you talking about procedures in different modules in a single workbook, or modules in different workbook projects. That's the key. I've been doing some more testing. I have two projects (.xlam files). Each project has 2-3 code modules. If I call a UDF in a different module in the same project, it works fine. It fails it it's in a different project. Is there a way to make all modules in all projects able to access all other modules in all other projects? Or, do I have to qualify the UDF name somehow, like Call projectname.modulename.udfname(arguments...) I would like to avoid the latter, if possible, so it will work even if I move the UDFs to different projects. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calling a module from another module | Excel Programming | |||
calling a module | Excel Discussion (Misc queries) | |||
calling another module from within module | Excel Programming | |||
Calling worksheet module from other module. | Excel Programming | |||
Calling VBA function that is in another module | Excel Programming |