How to run a sub from another open workbook?

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
I have a workbook LF-9.xlsm and I have "Public Sub RunLogic" there. How do I run it from another open workbook? I tried
Application.Run ("LF-9.xlsm!RunLogic")
but it says "Run-time error '1004': Cannot run the macro 'LF-9.xlsm!RunLogic'. The macro may not be available in this workbook or all macros may be disabled"

I tried to run it directly from the mdlSolverPart -module in that LF-9.xlsm workbook, and it has no problems at all. Running "internal" code in the calling workbook, UI-12.xlsm works without problems as well.

I'm using Excel2010.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
It doesn't seem to work for other macros in that workbook either. It shouldn't be about macro protection either, since I have enabled all macros (ie. disabled the whole security system).
 
Upvote 0
It appears the hyphen in the filename is the problem. Try single quotes around the name:
Application.Run "'LF-9.xlsm'!RunLogic"

You can also set a reference to LF-9.xlsm in the VBE if its a stable file name and location - under Tools | References. But you must give the vb project a unique name first under Properties (other than the default "VBProject").
 
Upvote 0
It appears the hyphen in the filename is the problem. Try single quotes around the name:
Application.Run "'LF-9.xlsm'!RunLogic"

You can also set a reference to LF-9.xlsm in the VBE if its a stable file name and location - under Tools | References. But you must give the vb project a unique name first under Properties (other than the default "VBProject").

Thank heavens I went to sleep before forcing everything into a single file, you have no idea how much this helps me! The fact is that I have a deadline with this project tonight and the chance to save like a couple of hours now because of your help increased the chances to get this done on time dramatically.

Please tell me if there's anything I can do for you.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,328
Members
452,907
Latest member
Roland Deschain

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