passing a macro from one workbook to a another workbook

mort1703

Active Member
Joined
Sep 13, 2008
Messages
265
Hi

I am expecting a NO to this question but if its possible I am all ears.

I have excel project I have been working on.

Within the project I create NEW workbooks based on set criteria and this seems to work without problems.

ie
1. Macro A - creates a NEW workbook based on criteria - working already
2. within Macro A - can I pass a module or a different macro to the workbook created within step 1.
3. if step 2 is possible, is it possible to code the transfer within Macro A.

Any help or advice on this one would be appreciated

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
Office Version
  1. 365
Platform
  1. Windows
Why not create a template with the code you want in the new workbooks and then use that when creating those new workbooks?
 

mort1703

Active Member
Joined
Sep 13, 2008
Messages
265
At the moment I am doing the following
1. run Macro A - this creates the NEW workbook
2. I then add the code manually.

just a thought

could I automate importing a module?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
Office Version
  1. 365
Platform
  1. Windows
Why don't you create a template workbook with the code and use that when creating the new workbook?

You can use code to import a module to a workbook but it has various implications, for example you would need to lower the security settings to allow programmatic access to VBE.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,048
Messages
5,639,769
Members
417,111
Latest member
buyukbang

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