ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Playing a macro from another workbook (https://www.excelbanter.com/excel-discussion-misc-queries/14682-playing-macro-another-workbook.html)

Jim

Playing a macro from another workbook
 
I have a workbook that contains a macro I need to run on a large number of
other workbooks. Is it possible to play a macro from another workbook on the
current workbook with out copying either the data or the macro manually?

I've found that if I open the workbook containing the macro, and then open
one of the "target" workbooks, I can open the Run Macro dialog box in the
target workbook and all macros in both workbooks are displayed if "All Open
Workbooks" is selected in the "Macros in:" field on the Macro dialog.
However if I select the macro I need to run from the "source" workbook, the
macro only runs on it's workbook, not the "target".

Without copying and pasting the data from the target workbooks into the
source workbook and then running the macro, is there a simpler way?

Thanks for any help

Dave Peterson

Usually when you want your code to run against lots of workbooks, you write it
using Activesheet references and activeworkbook (not ThisWorkbook).



Jim wrote:

I have a workbook that contains a macro I need to run on a large number of
other workbooks. Is it possible to play a macro from another workbook on the
current workbook with out copying either the data or the macro manually?

I've found that if I open the workbook containing the macro, and then open
one of the "target" workbooks, I can open the Run Macro dialog box in the
target workbook and all macros in both workbooks are displayed if "All Open
Workbooks" is selected in the "Macros in:" field on the Macro dialog.
However if I select the macro I need to run from the "source" workbook, the
macro only runs on it's workbook, not the "target".

Without copying and pasting the data from the target workbooks into the
source workbook and then running the macro, is there a simpler way?

Thanks for any help


--

Dave Peterson


All times are GMT +1. The time now is 02:38 AM.

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