Run code from separate workbook

mikechambers

Active Member
Joined
Apr 27, 2006
Messages
397
I have several master files that need to run the same code, so I want to keep only one set of code in a separate workbook for easier maintenance. The code works fine, but I have the button in each of the masters to click on to run the macro. It first opens up the code-only workbook, which then becomes the active workbook, so all the code is performed on that workbook instead of the master. I obviously am trying to avoid telling Excel to activate the specific master file since it will be different in each case. So my question is, how can I activate the master file without specifying a file name, OR how can I open the code-only workbook and run the macro without activating that workbook? Any help would be greatly appreciated!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Joined
Jul 30, 2006
Messages
3,656
mike,

You could put the code in your Personal.xls file, available in the VBA Editor.

If it is not available in the list on the left side of the VBA Editor, you could, from one of your workbooks:
Tools, Macro, Record New Macro...

In the 'Store macro in:' box, pick 'Personal Macro Workbook', and click on 'OK'.

Then stop the macro.

Then copy the master workbook macro into the 'Personal.xls' Module1.

Have a great day,
Stan
 

Forum statistics

Threads
1,181,405
Messages
5,929,756
Members
436,687
Latest member
Glass of Gin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top