ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run module in another workbook (https://www.excelbanter.com/excel-programming/375907-run-module-another-workbook.html)

geebee

run module in another workbook
 
hi,

I have a Sub Option_Change() in a module called OptionChanger. I would like
to know how I can refer to this module and run it from another workbook?

Thanks in advance,
geebee


Mike Fogleman

run module in another workbook
 
Here is an example from my workbook named NCP Work.xls. It will open (NCP
Tracking.xls) and run a macro (RunUpdate) in that workbook that is in the
same folder path.

Sub RunTracking()
Dim cdir As String
Dim wb As Workbook

For Each wb In Workbooks
If wb.name = "NCP Tracking.xls" Then
MsgBox ("NCP Tracking.xls is already open.")
Exit Sub
End If
Next wb
cdir = ActiveWorkbook.Path
Workbooks.Open cdir & "\NCP Tracking.xls", password:="NCP"
Application.Run ("'NCP Tracking.xls'!RunUpdate")
End Sub

Mike F
"geebee" (noSPAMs) wrote in message
...
hi,

I have a Sub Option_Change() in a module called OptionChanger. I would
like
to know how I can refer to this module and run it from another workbook?

Thanks in advance,
geebee





All times are GMT +1. The time now is 07:16 AM.

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