How to save Function code in an exported workbook ?

Sparkle99

Board Regular
Joined
May 22, 2009
Messages
119
I have a Workbook that generates a new worksheet that gets saved into a separate file for emailing to customers to fill-in and return.

The Workbook has functions that are used in formulas on the new sheet. So, when the new sheet is copied and saved to a new file, the function code is missing.
The Functions are in Module1.

How do I get the code into the new workbook ?
As the code is in functions, I can't just put the code onto the worksheet itself.
So, are functions the right way to do this ?

The code needs to be in place in the new Workbook or the naiive user will get errors.
Does anyone have any suggestions ?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Many thanks Peter.
The code looks... interesting !
I think I get what is happening and have copied the code and made the various settings changes required.

Can I just clarify the use of "FromVBProject" and "ToVBProject"
Should these be the filenames of the 'Main XLS' and the 'Exported XLS' - the latter being where i wish to copy the Module of code ?
 
Upvote 0
It would be like this

Code:
retval = CopyModule("Functions", ThisWorkbook.VBProject, ActiveWorkbook.VBProject, True)
 
Upvote 0
Many thanks Peter - it works a treat.

Forum question...
Is it possible to 'close' these threads ?
My question has been answered - the thread can be found by searching.
 
Upvote 0

Forum statistics

Threads
1,224,526
Messages
6,179,322
Members
452,906
Latest member
Belthazar

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
Back
Top