How Do I Batch Send All Worksheets in One Excel Workbook as Attachments In Separate Emails

CherieLewis

New Member
Joined
Feb 14, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I found the following code, which works great, but it embeds the worksheets in the email. How do I tweak it so that each worksheet is an attachment to the email? I have 13 worksheets in a workbook and they all have a unique name, so I'm not sure if that plays in to this.

Code:
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Whenever you want to write code, first envision what it should do. Next if you prefer, write the logic down on a piece of paper or type it in a notepad. Only when the logic is clear will you be able to code.

Now couple of questions

Since each worksheet is going as an attachment in a separate email, is there any criteria as to what should be the email address or the subject or email body content? Or you want to simply loop through the worksheets and send them 1 by one to the same email recipient with the same subject etc etc. What is the logic that you want to follow? If you can explain all of that in your post, it will be easier for me to assist you in your query.
 
Upvote 0
I am trying to accomplish an easier way to send out commissions to our sales reps. Currently, our controller attaches each excel worksheet from a workbook and email one by one. There are 13-20 reps that could receive the email. The worksheets are named for the rep. I was hoping to make the process faster. The subject would be commissions. It would be nice if I could tie an email address to the rep name on the worksheet, but I could also work with a macro that fills in a generic email and I can change it. I don't believe the controller adds any message in the body of the email. Does this help?
 
Upvote 0
If I have understood you correctly, then this should be your logic.

To make your job easier and for the macro to work without any errors do this

1. Create a Sheet called, say, "Employee Data". In Column A, put employee names, In Column B, add their email addresses.
2. Loop though the above employee data and check if there is any worksheet with that name. And if there is, then simply copy that worksheet to a new workbook and then email it.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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