Transferring Modules

Submersed

Board Regular
Joined
Jul 6, 2007
Messages
167
Office Version
  1. 365
Platform
  1. Windows
Hi,

I was wondering if it is possible to transfer code that is in a module activated by a button into a sheet?

many thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,941
Why not just call the code in the sheet? You can call sub routines within the sheet code.
 
Upvote 0

Submersed

Board Regular
Joined
Jul 6, 2007
Messages
167
Office Version
  1. 365
Platform
  1. Windows
The problem is...I copy a few sheets and make a new workbook with them..then i send this workbook to someone but they can't use the macro's because they are all in the modules on the original workbook...So i thought if they are in the sheets wouldn't that work??
 
Upvote 0

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,941
I'm not positive that the code would transfer with the copy. I know that code on sheets can be picky at times on what you can do. Sometimes the code has to be in a module to work properly. You can export modules and e-mail them the module and then they can import it into the workbook. There may even be a way through VBA to export a module, but I do not know it.
 
Upvote 0

Submersed

Board Regular
Joined
Jul 6, 2007
Messages
167
Office Version
  1. 365
Platform
  1. Windows
ok no worries...I'll try and do something
 
Upvote 0

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
Why not create a copy of the workbook, then delete the unneeded worksheets from the copy and send that.

The code should be intact if you do that.
 
Upvote 0

Submersed

Board Regular
Joined
Jul 6, 2007
Messages
167
Office Version
  1. 365
Platform
  1. Windows
is there some code that will copy the enitre workbook then??

when I just copy all the sheets into a new workbook...the modules don't go along with it...
 
Upvote 0

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
5,271
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
You can manually Save As, or make a copy in Windows Explorer. Or in code:

ActiveWorkbook.SaveAs "C:\temp\Copy1.xls"

or

ActiveWorkbook.SaveCopyAs "C:\temp\Copy2.xls"

SaveAs changes the active workbook to Copy1.xls, while SaveCopyAs keeps the original workbook as the active workbook.
 
Upvote 0

Forum statistics

Threads
1,191,498
Messages
5,986,915
Members
440,064
Latest member
Pluong91

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