View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How to make a custom function to work in another workbook

Change the name of the VBProject that contains the function from the default
"VBA Project" to something meaningful like "projMathStuff". To do this, open
the project containing the function, go to the Tools menu in VBA, choose
"VBA Project Properties" and change the value of the Name parameter. Now, to
allow other workbooks to call that function, the other workbook needs to set
a reference to the "projMathStuff" project. In the calling workbook, go back
to the Reference dialog and put a check next to the "projMathStuff" item.
With that reference in place, you can call the function as if it were built
in to the workbook:

Res = TheFucntion(1,2,3)

If there is the possibility that more than one workbook may have a function
named TheFunction, you can prefix the call with the library name. E.g.,.

Res = projMathStuff.TheFunction(1,2,3)


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Gerardo" wrote in message
...
I have one function stored in a module of a workbook, I'll like to use it
in
a different workbook. At the begining of the function I used the Public
statement, do I need to do something else? I do keep open the source
workbook.

regards