Premium Excel Course Now Available!
Build Professional - Unbreakable - Forms in Excel
45 Tutorials - 5+ Hours - Downloadable Excel Files
Instant Access! - Lifetime Access!
Email List of People from Excel Using a Macro
Add to Favorites
Favorited
Send Emails from Excel Course
Send emails to everyone in a list in Excel using a macro. The message for the email can either come from another column in the list and be unique for each email or be the same for each email.
The emails will be sent through Microsoft Outlook, so you must also have that program setup on your computer.
Sections:
The Macro
Edit the Macro
The Macro
The macro pulls the email addresses from column A and the message text from column B.
It assumes that the email list starts in row 1; to change this, go to the section below the macro that explains how to edit it.
Sub Send_Email_to_List()
'
' Full Email Course: https://www.teachexcel.com/premium-courses/96/send-emails-from-excel-course?src=1884_tutorial
'
Dim OL As Object, MailSendItem As Object
Dim MsgTxt As String
Set OL = CreateObject("Outlook.Application")
For Each xCell In ActiveSheet.Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
user_email = xCell.Value
user_subject = "Subject Line for the Email"
user_msg = Cells(xCell.Row, 2).Value
Set MailSendItem = OL.CreateItem(olMailItem)
With MailSendItem
.Subject = user_subject
.Body = user_msg
.To = user_email
.Send
End With
Next xCell
Set OL = Nothing
End Sub
Edit the Macro
Change the Email List
Range("A1"), Range("A" & Rows.Count).End(xlUp)
Change A1 to the cell that starts the email list. If you change from column A to another column, also change "A" to the letter of the column with the list.
If the email list is in a pre-defined range, you can replace the bold text above with a simple range input like this: "A1:A100" and that tells the macro that the emails are contained in cells A1 to A100.
The original code will start from the first cell in the list, A1, and go to the very last cell in that column that has data.
Change the Subject Line
"Subject Line for the Email"
Change the above piece of code to whatever you want to be in the subject.
You can even get the value from the spreadsheet if you want, just reference the cell in the same way that the message body text is referenced.
Change the Message Body Text
Cells(xCell.Row, 2).Value
This piece of code tells the macro to get the body text of the email from column B in the same row as the email address.
To change the column from which the text is gotten, simply change 2 to the number of the desired column; A is 1, B is 2, etc.
To change this to a generic message for each user, simple reference the cell that contains the generic message like this: Range("A1").Value and the message will be taken from the specified cell.
You could also replace the code with text directly in the macro like this: "This is the email message."
Excel VBA Course - From Beginner to Expert
200+ Video Lessons
50+ Hours of Instruction
200+ Excel Guides
Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)
View Course
()
Quickly Create a Huge List of Numbers in Excel
Tutorial:
Quickly create a large list of numbers in Excel using the Fill Command. This will save ...
Macro to Open a Website from Excel
Tutorial: How to open a website in the browser from Excel using a Macro and VBA.
This is the same as...
Login to a Website using a Macro
: Connect and login to a website using a macro in Excel.
This allows you to open a website a...
Put Data into a Worksheet using a Macro in Excel
Tutorial: How to input data into cells in a worksheet from a macro.
Once you have data in your macro...
Loop through a Range of Cells in Excel VBA/Macros
Tutorial: How to use VBA/Macros to iterate through each cell in a range, either a row, a column, or ...
Automatically Lock Certain Cells in Excel using a Macro
Tutorial: This macro allows you to have a cell automatically locked after a user enters something in...
How to Install the Macro
- Select and copy the text from within the grey box above.
- Open the Microsoft Excel file in which you would like the Macro to function.
- Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.
Or For other ways to get there, Click Here.
For Excel Versions Prior to Excel 2007
Go to Tools > Macros > Visual Basic Editor
For Excel 2007
Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic
- On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.
- If the Macro goes in a Module, Click Here, otherwise continue to Step 8.
- Go to the menu at the top of the window and click Insert > Module
- Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
- Go to Step 8.
- If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Go to Step 8.
- If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
- Go to Step 8.
- Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.
- You are now ready to run the macro.