from workbook2 switch to workbook3 and run a macro


Posted by jeff on July 17, 2001 1:26 PM

Is it possible to switch from one workbook to another workbook and run a macro? Both workbooks are already open.

Posted by Barrie Davidson on July 17, 2001 1:50 PM

Yes, see below.

Sub YourMacroName()
Dim FirstWorkBook As String 'variable to hold the name of the first workbook
Dim SecondWorkBook As String 'variable to hold the name of the second workbook

Windows(SecondWorkBook).Activate 'goes to the second workbook

'the rest of your macro follows

End Sub

Hope this helps you out.

Barrie

Posted by jeff on July 17, 2001 2:42 PM

Posted by Barrie Davidson on July 17, 2001 2:49 PM

Jeff, nothing came through in your message

Posted by jeff on July 17, 2001 2:51 PM

i need to write a macro for workbook2 that calls workbook3 and runs a macro named "test". the macro "test" is stored with workbook3 and both workbooks are open. is there a way to start/run a macro?



Posted by Barrie Davidson on July 17, 2001 3:00 PM

Now I understand. Try this:
Application.Run "'workbook3.xls'!test"

Regards,
Barrie