run vba function from different xls file

bestox

Board Regular
Joined
Apr 2, 2009
Messages
82
i would like to run a function from another file (in the same directory) and want to save the return value (it s a string) to a local string variable.

unfortunately, this

Code:
dim x as string
x = Run "'filename.xls'!Modul1.update"

does not work.

what code do i need, to save the result of the function to my variable x?

thank you!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Have you tryed getting the file to open your other file and running the script with a call function?
 
Upvote 0
my mistake.

this works:
Code:
Run "'filename.xls'!Modul1.update"

but this does not work:

Code:
dim x as string
x = Run "'filename.xls'!Modul1.update"
 
Upvote 0
maybe is should add, that function update looks like that:

Code:
Function update() As String
 
Upvote 0
Code:
dim x as string
x = Application.Run("'filename.xls'!Modul1.update")
should do it.
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top