How to call up a macro in a different location?

T

Tom

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
 
D

Dave Peterson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top