Reputation: 317
I currently run a sub in another (open) workbook using this line:
Application.Run ("'NDS Analytics.xlsm'!Process")
The names of the referenced workbooks are changing so I would like to change the reference so that instead of looking for file NDS Analytics.xlsm it looks for an open file that contains the words "NDS Analytics".
There will only ever be one file with this name open at a time and it could be called either NDS Analytics.xlsm, wNDS Analytics.xlsm or 40ghNDS Analytics.xlsm.
Upvotes: 0
Views: 124
Reputation: 55073
Option Explicit
Sub runProcess()
Dim wb As Workbook
For Each wb In Workbooks
If UCase(wb.Name) Like UCase("*NDS Analytics*.xlsm") Then
Application.Run "'" & wb.Name & "'!Process"
Exit For
End If
Next wb
End Sub
Upvotes: 2