ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to call up a macro in a different location? (https://www.excelbanter.com/excel-discussion-misc-queries/170026-how-call-up-macro-different-location.html)

Tom

How to call up a macro in a different location?
 
When I am running a macro "ABC" located in Personal.xls, how can I
call up a macro "XYZ" located in another open workbook,
MyWorkBook.xls? Thanks for your help.

TIA
Tom


Dave Peterson

How to call up a macro in a different location?
 
Dim wkbk as workbook
dim macroname as string
set wkbk workbooks("myworkbook.xls") 'it has to be open
macroname = "xyz"
application.run "'" & wkbk.name & "'!" & macroname

==
or just
application.run "myworkbook.xls!xyz"
or
application.run "'my workbook.xls'!xyz"
(if your workbook name has spaces)


Tom wrote:

When I am running a macro "ABC" located in Personal.xls, how can I
call up a macro "XYZ" located in another open workbook,
MyWorkBook.xls? Thanks for your help.

TIA
Tom


--

Dave Peterson


All times are GMT +1. The time now is 08:26 PM.

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