bloodmilksky
Board Regular
- Joined
- Feb 3, 2016
- Messages
- 202
Hi Guys, I hope you are all well today
I have been using the below to fire off emails to customers. So their Account number appears in Column A & their email in Column B and it then sends off information row by row (C3:I3) to each customer.
What I was wondering if anyone knows how I may Amend this code to email named ranges instead of rows.
So the ranges would be A1:B10,C1:D10,E1:F10 and so on with their account number in A1 & email in B1 and information below.
Any help would be greatly appreciated
Many thanks
Bloodmilksky

I have been using the below to fire off emails to customers. So their Account number appears in Column A & their email in Column B and it then sends off information row by row (C3:I3) to each customer.
What I was wondering if anyone knows how I may Amend this code to email named ranges instead of rows.
So the ranges would be A1:B10,C1:D10,E1:F10 and so on with their account number in A1 & email in B1 and information below.
Code:
Sub EmailRanges()
' Defines variables
Dim OutlookApp As Object, Mess As Object, SendAddress As String, Cell As Range, cRange As Range
' Disable screen updating
Application.ScreenUpdating = False
' Defines LastRow as the last row of column A containing data
LastRow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
' Sets the range to check for email addresses
Set cRange = ActiveSheet.Range("B3:B" & LastRow)
' For each cell in the check range
For Each Cell In cRange
' If the cell is not blank then
If Cell.Value <> "" Then
' The desired send address will be the cell value
SendAddress = Cell.Value
' Select the range of cells on the active worksheet.
ActiveSheet.Range("C" & Cell.Row, "I" & Cell.Row).Select
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True
' Set the optional introduction field thats adds
' some header text to the email body. It also sets
' the To and Subject lines. Finally the message
' is sent.
With ActiveSheet.MailEnvelope
.Introduction = "Good Morning"
.Item.To = SendAddress
.Item.Subject = "Just testing this macro sorry for filling you inbox ^_^ "
.Item.Send
End With
End If
' Check next cell in the check range
Next Cell
' Re-enable screen updating
Application.ScreenUpdating = True
MsgBox "The Customers Have Been Notified"
End Sub
Any help would be greatly appreciated
Many thanks
Bloodmilksky