VBA & Macro Problems

Fix Duplicate Recipient and Subject Values in Excel VBA Emails

Jason MillerJason Miller Nov 18, 2026 869 views

Question details

The user needs an Excel VBA macro to create one email per qualifying row using that row's recipient and subject.

Fix Duplicate Recipient and Subject Values in Excel VBA Emails
Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
A macro generates emails from worksheet rows and includes a date in each email body.
Observed behavior
The date appears correctly, but the macro repeats the same recipient and subject across messages. Multiple messages to the same recipient are valid when separate rows qualify.
Before you start

Identify the columns containing the recipient, subject, and date, and confirm the condition that makes a row eligible. The example below uses Outlook automation, so check that a compatible desktop version of Outlook is installed and configured.

Solution 1Recommended

Read Email Values Inside the Excel VBA Row Loop

Use this approach to create a separate Outlook draft for each qualifying worksheet row without filtering out repeated recipients.

The example assumes headers in row 1, recipients in column A, subjects in column B, and dates in column C. It qualifies dates on or after today; change the column references and date condition to match your worksheet.

A repeated recipient or subject is not necessarily an error. Separate qualifying rows can legitimately produce messages with the same recipient or subject.

1
Open the VBA editor

In Excel, open Developer > Visual Basic, then open the module containing your email macro. If the Developer tab is hidden, enable it in Excel's ribbon settings.

2
Update the row loop

Use the following example as a guide. It reads the recipient and subject inside the loop, checks each row's date, and creates a new email object for each qualifying row: Sub CreateRowEmails() Dim ws As Worksheet Dim outlookApp As Object Dim mail As Object Dim lastRow As Long Dim rowNum As Long Dim rowDate As Date Set ws = ActiveSheet Set outlookApp = CreateObject("Outlook.Application") lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row For rowNum = 2 To lastRow If Trim(ws.Cells(rowNum, "A").Value) <> "" And IsDate(ws.Cells(rowNum, "C").Value) Then rowDate = DateValue(ws.Cells(rowNum, "C").Value) If rowDate >= Date Then Set mail = outlookApp.CreateItem(0) With mail .To = ws.Cells(rowNum, "A").Value .Subject = ws.Cells(rowNum, "B").Value .Body = "Date: " & Format(rowDate, "mm/dd/yyyy") .Display End With Set mail = Nothing End If End If Next rowNum End Sub

3
Test the generated messages

Select the intended worksheet, then run CreateRowEmails from Developer > Macros. Check that each eligible row opens one message with its own recipient, subject, and date, including rows that share a recipient.

Read Email Values Inside the Excel VBA Row Loop
Review before sending: The example uses .Display rather than .Send so you can inspect the messages. It skips rows with a blank recipient or an invalid date; adjust those checks and the date condition as needed.
Free Microsoft Office alternative

Work with Excel-Compatible Spreadsheets in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move everyday spreadsheet work. It does not fix Excel's VBA or Outlook automation behavior; check macro compatibility before migrating an automated workbook.

Review and edit worksheet data in a familiar spreadsheet interface.Open and save common Microsoft Excel formats, including XLSX.Use a lightweight suite with free tools for everyday Office work.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my macro repeat the same recipient and subject?

The macro may be reading those values outside the row loop or using fixed cell references. Read the recipient and subject from the current row inside each iteration before creating the email.

Should I remove duplicate recipient addresses before generating emails?

Not if each qualifying row represents a separate message. The example creates one message per qualifying row even when multiple rows have the same recipient.

How do I change which dates qualify?

In the VBA editor, replace the condition `If rowDate >= Date Then` with the rule you need. For example, `If rowDate = Date Then` selects only rows dated today.

Does the example send emails automatically?

No. It uses Outlook's `.Display` method to open each message for review. Check the recipient, subject, and body before sending.