Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default return a value from a vba function in another xla

How do I get the value a function returns from another xla
I am trying to use the code
returnedValue = Excel.Application.Run "xlaname.xla!functionname",
functionparameter1, functionparameter2

I keep getting "expected end statement"

If the statement is on its own it runs but I dont get the value it returns,
that is
Excel.Application.Run "xlaname.xla!functionname", functionparameter1,
functionparameter2


I need the value that the function returns. How do I do this with out
making changes to the function.
Regards,
Emily

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default return a value from a vba function in another xla

i have not tried it but, this looks right.

Excel.Application.Run "xlaname.xla!functionname"( functionparameter1,
functionparameter2)




"Emily" wrote in message
...
How do I get the value a function returns from another xla
I am trying to use the code
returnedValue = Excel.Application.Run "xlaname.xla!functionname",
functionparameter1, functionparameter2

I keep getting "expected end statement"

If the statement is on its own it runs but I dont get the value it
returns,
that is
Excel.Application.Run "xlaname.xla!functionname", functionparameter1,
functionparameter2


I need the value that the function returns. How do I do this with out
making changes to the function.
Regards,
Emily



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default return a value from a vba function in another xla

This was saved from a post for a similar question. You'll have to change the
workbook name from personal.xls to the real name.

Dim pWkbk as workbook
set pwkbk = workbooks("Personal.xls")
application.run "'" & pwkb.name & "'!macronamehere", "parm1", "parm2"

or if you're returning a value from a function:

dim res as string 'or variant or long or ...
res = application.run("'" & pwkb.name & "'!macronamehere", "parm1", "parm2")

You could also create a reference to this personal.xls workbook and call it just
like it was built into excel.

Tools|references
(but give the personal.xls's project a nice unique name (not VBAProject).

ps.

If you're using a function living in personal.xls inside a cell:
=personal.xls!functionnamehere(a1,b1,c1)

or save the file as an addin (*.xla) and use it in the cell like it's built into
excel:
=functionnamehere(a1,b1,c1)

Emily wrote:

How do I get the value a function returns from another xla
I am trying to use the code
returnedValue = Excel.Application.Run "xlaname.xla!functionname",
functionparameter1, functionparameter2

I keep getting "expected end statement"

If the statement is on its own it runs but I dont get the value it returns,
that is
Excel.Application.Run "xlaname.xla!functionname", functionparameter1,
functionparameter2

I need the value that the function returns. How do I do this with out
making changes to the function.
Regards,
Emily


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default return a value from a vba function in another xla

thanks. that did help. I needed the put brakets after the run to return the
value. I had tried putting brackets in but after the function name, which
did not work.
thanks also for the other tips which will be useful.
Emily

"Dave Peterson" wrote:

This was saved from a post for a similar question. You'll have to change the
workbook name from personal.xls to the real name.

Dim pWkbk as workbook
set pwkbk = workbooks("Personal.xls")
application.run "'" & pwkb.name & "'!macronamehere", "parm1", "parm2"

or if you're returning a value from a function:

dim res as string 'or variant or long or ...
res = application.run("'" & pwkb.name & "'!macronamehere", "parm1", "parm2")

You could also create a reference to this personal.xls workbook and call it just
like it was built into excel.

Tools|references
(but give the personal.xls's project a nice unique name (not VBAProject).

ps.

If you're using a function living in personal.xls inside a cell:
=personal.xls!functionnamehere(a1,b1,c1)

or save the file as an addin (*.xla) and use it in the cell like it's built into
excel:
=functionnamehere(a1,b1,c1)

Emily wrote:

How do I get the value a function returns from another xla
I am trying to use the code
returnedValue = Excel.Application.Run "xlaname.xla!functionname",
functionparameter1, functionparameter2

I keep getting "expected end statement"

If the statement is on its own it runs but I dont get the value it returns,
that is
Excel.Application.Run "xlaname.xla!functionname", functionparameter1,
functionparameter2

I need the value that the function returns. How do I do this with out
making changes to the function.
Regards,
Emily


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can VBA function be used to return value Andrew[_56_] Excel Programming 3 May 13th 09 06:33 PM
Return Function scott Excel Worksheet Functions 2 October 21st 08 10:26 PM
Return value for a function. Jeff Excel Discussion (Misc queries) 1 June 2nd 08 09:08 PM
Only do Sum function if not "0", IF"0" then return "0" Mike Punko Excel Worksheet Functions 1 June 1st 05 12:20 AM
Function to return value from each tab Steven Leuck Excel Worksheet Functions 1 March 3rd 05 04:11 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"