Losing VBA when emailing spreadsheet

bclor3591

New Member
Joined
Oct 7, 2010
Messages
33
Is there a way to send the VB code for buttons and macros with the spreadsheet when emailing from within excel? I have a button to send a spreadsheet through outlook, but when the file arrives at recipient the code and macro are not there.
 

VBA Geek

MrExcel MVP
Joined
Dec 16, 2013
Messages
2,857
You want to email the whole workbook including its code? or just one worksheet of your workbook
 

bclor3591

New Member
Joined
Oct 7, 2010
Messages
33
Hello VBA Geek,

Yes, I'm trying to email 1 spreadsheet with 3 buttons (with the 2 macros and the VB code). The buttons work fine, but when I send the file the buttons show up with the data on the aspreadsheet, but the VB cose and macros doesn't go with the spreadsheet. I can send the code if you need it. I have to figure out how to attach VB code and macros to this post???
 

VBA Geek

MrExcel MVP
Joined
Dec 16, 2013
Messages
2,857
The two buttons are Active X controls, command button? whereas the 3rd is in a standard module?
 

bclor3591

New Member
Joined
Oct 7, 2010
Messages
33
Under the Developer Tab, Actually, all 3 buttons are Active X Controls. Then I added a MODULE down at the Worksheet level and that is where I put the LESS DATA & MORE DATA macros. The VB code that has the CommandButton1-3 logic was added to the Sheet1 worksheet.
 

VBA Geek

MrExcel MVP
Joined
Dec 16, 2013
Messages
2,857
if you use

thisworkbook.sheets("sheetToemail").copy

the new workbook will contain just this worksheet and the code at the worksheet level should be in there too
 

bclor3591

New Member
Joined
Oct 7, 2010
Messages
33
Hello VBA Geek,

I tried to add the code above to my code, but I'm not quite sure where it needs to go. I can send you the code for your review if I can figure out how to attach it to these posts?
 

Forum statistics

Threads
1,082,380
Messages
5,365,124
Members
400,824
Latest member
Themilkybarkid

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top