Email List of People from Excel Using a Macro

Add to Favorites
Author:

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."

ecf6ea55918e3484392d1c516d0ec85c.jpg






Excel VBA Course
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

Similar Content on TeachExcel
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
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. 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.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  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.

  9. You are now ready to run the macro.

Tutorial Details
Downloadable Files: Excel File
Similar Content
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...
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
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