Unfortunately I’ve had to remove the macro from the file, as I’m unable to upload a. VBA code for sorting can get quite complicated, and it can sometimes be a good idea to do the sort on the front end of Excel and record a macro to show you how the code works. I’ve provided the Excel file template if you’d like to experiment and practice using the file. Outlookmailitem.body = Sheet7.Cells(7, x) Set myAttachments = outlookmailitem.Attachments Type or paste the code in the newly created module. Right-click the project/workbook name in the Project window. Set outlookmailitem = outlookapp.createitem(0) To use this macro, you can copy and paste it into a standard module: Activate the Visual Basic Editor by pressing ALT+F11. Set outlookapp = CreateObject("Outlook.Application") You can do this by pressing the Alt + F11 keys on your keyboard (or Option + F11 on Mac). You’ll need to start by opening the Visual Basic Editor in your Excel workbook. I needed a way to copy and paste the table into an Excel sheet, which would then automatically create unique emails for 23 different Sales Offices.Įach unique email would need to summarize the performance of the Sales Office and have a unique email attachment. To begin creating a VBA macro using a For Loop in the Visual Basic Editor, you can follow these steps: Step 1: Open the VBA Editor. I can also download the data (which contains website visitors, leads and sales) into one table in Excel.īelow is the table with the data (the data currently in there is all random numbers generated by the formula =RANDBETWEEN()).
What I needed the macro to do for meįrom a database, I could download separate sales reports for each country. In this post, I won’t go through a step by step guide on how sending emails using Excel is possible using macros and VBA options in Microsoft Excel.
I’ll explain how I used the template detailed in the video above, and used it to accomplish the task I needed to automate. Here is a method for how to send Emails using a VBA macro in Excel.