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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Alteran

Board Regular
Joined
Nov 25, 2009
Messages
117
Have you tryed getting the file to open your other file and running the script with a call function?
 

bestox

Board Regular
Joined
Apr 2, 2009
Messages
82
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"
 

bestox

Board Regular
Joined
Apr 2, 2009
Messages
82

ADVERTISEMENT

maybe is should add, that function update looks like that:

Code:
Function update() As String
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,941
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Code:
dim x as string
x = Application.Run("'filename.xls'!Modul1.update")
should do it.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,991
Messages
5,656,270
Members
418,292
Latest member
spd87

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
Top