ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run VB sub from one workbook to another (https://www.excelbanter.com/excel-programming/386167-run-vbulletin-sub-one-workbook-another.html)

MDW

Run VB sub from one workbook to another
 
I've got two workbooks, Model.xls and Shell.xls.

Model.xls contains a sub called "my_sub". It's defined as "Public Sub
my_sub()".

I need to open Model.xls using VBA code in Shell.xls and then run the sub
"my_sub". I know how to open one file from within another, but I don't know
how to call a sub. Any pointers on how to do this?

--
Hmm...they have the Internet on COMPUTERS now!

MDW

Run VB sub from one workbook to another
 
Thanks - I knew it was something simple.
--
Hmm...they have the Internet on COMPUTERS now!


"Gary''s Student" wrote:

Consider:

Sub MDW()
ActiveWorkbook.FollowHyperlink Address:="file:///c:\model.xls"
Application.Run "Model.xls!my_sub"
End Sub

The FollowHyperlinks will open the file if not already open.
--
Gary''s Student
gsnu200712


Gary''s Student

Run VB sub from one workbook to another
 
Consider:

Sub MDW()
ActiveWorkbook.FollowHyperlink Address:="file:///c:\model.xls"
Application.Run "Model.xls!my_sub"
End Sub

The FollowHyperlinks will open the file if not already open.
--
Gary''s Student
gsnu200712



All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com