ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call a Sub from another Worksheet (https://www.excelbanter.com/excel-programming/442072-call-sub-another-worksheet.html)

Mike H.

Call a Sub from another Worksheet
 
I can't seem to get this to work:
Dim wb As Workbook
Set wb = Workbooks.Open("z:\journal entry.xlsm")
Application.Run wb.Name & "!CreateSubmittal"

The Sub CreateSubmittal is designated as "Public Sub CreateSubmittal()" or
not.
The Sub is in the THisWorkbook object or Module1. Neither works.

Ideas? Thanks!

JLGWhiz[_2_]

Call a Sub from another Worksheet
 
Hi Mike, It's all in the Quote marks. Note the Apotrophe enclosed in double
quotes on both ends of the file name variable.

Application.Run "'" & wb.Name & "'" & "!CreateSubmittal"




"Mike H." wrote in message
...
I can't seem to get this to work:
Dim wb As Workbook
Set wb = Workbooks.Open("z:\journal entry.xlsm")
Application.Run wb.Name & "!CreateSubmittal"

The Sub CreateSubmittal is designated as "Public Sub CreateSubmittal()" or
not.
The Sub is in the THisWorkbook object or Module1. Neither works.

Ideas? Thanks!





All times are GMT +1. The time now is 03:39 PM.

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