PC Review


Reply
Thread Tools Rate Thread

How to Call Functions in the Personal Workbook?

 
 
SteveM
Guest
Posts: n/a
 
      18th Dec 2007
I'm working on an Excel Project and would like to use some utility
functions resident in my Personal Workbook. Is there a simple/
standard way to access those functions from the other Project?

Or is cutting and pasting the code the non-elegant, best way?

Thanks Much,

SteveM
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Dec 2007
In a formula in a cell:
=personal.xls!myfunct(a1:b99)

If you saved your personal workbook as an addin (personal.xla), then you can
refer to the functions in that addin just like they were built into excel:
=myfunct(a1:b99)

If you want to access the functions in your other project (via code), you have a
couple of choices.

You could add a reference in the "receiving" project that points at the
"sending" project.

First, it's probably better to give the "sending" project a nice unique name.
Open the VBE
Hit ctrl-r to see the project explorer
select your workbook's project.
It should look something like: VBAProject (book1.xls)
Hit F4 to see the properties window
Type the new name in the (Name) property

Save this workbook.

Select the "receiving" project
Tools|References
Look for that nice unique name and select it (check it).

Then you can use the functions in that other workbook just like they're built
into VBA.

Dim Resp as long
resp = myFunct(activesheet.range("a1:A7")

======

The second way to have your code call a function in another workbook's project
is to use Application.run:

application.run "'FullfileName.xls'!macroname", myargument
or to return something:
resp = application.run("'fullfilename.xls"'!macroname, myargument)

SteveM wrote:
>
> I'm working on an Excel Project and would like to use some utility
> functions resident in my Personal Workbook. Is there a simple/
> standard way to access those functions from the other Project?
>
> Or is cutting and pasting the code the non-elegant, best way?
>
> Thanks Much,
>
> SteveM


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Macros, User-Defined Functions, and the Personal Macro Workbook Ken Johnson Microsoft Excel Discussion 4 26th Apr 2009 08:01 PM
How do I call up a line of code that references a cell/range in theactive workbook workbook where I am running my macro from? Lav Microsoft Excel Programming 1 11th Nov 2008 05:04 PM
User Defined Functions in the Personal Macro Workbook Nate Microsoft Excel Discussion 2 11th May 2006 04:31 PM
Please help - How to call functions that exists in the main application. The call should be initiated from one of the components. Anand Ganesh Microsoft C# .NET 5 16th Oct 2004 01:53 AM
Re: Please help - How to call functions that exists in the main application. The call should be initiated from one of the components. Baavgai Microsoft C# .NET 0 4th Sep 2004 05:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:03 PM.