-
Solved: Using a String to Run a Macro
Hi all - Can anyone please advise how to acheive the following please? I can run a macro contained within a sheet by using the following...
[VBA]Run "'A Workbook.xls'!MyMacro"[/VBA]
Unfortunately I need to refer to the workbook as a String. So I would need something like...
[VBA]Run "'myWorkbook'!MyMacro"[/VBA]
But this doesn't work
Can anyone please help out?
Cheers,
rrenis
-
Knowledge Base Approver
The King of Overkill!
VBAX Master
You can use the & symbol to concatenate strings, like
[vba]Application.Run "'" & myWorkbook & "'!MyMacro"[/vba]if myWorkbook is a workbook type variable, use myWorkbook.Name instead
Matt
-
Thanks - not at work at the moment but I'll try it tomorrow and let you know how it goes!!
-
Hi mvidas
Thanks for your help - just tried it and it works perfectly! Thank you.
Cheers,
rrenis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules