antonschoene
New Member
- Joined
- Jul 1, 2014
- Messages
- 2
Hello everyone, I am new to the forum and am really stuck with this macro. I have searched and found multiple macros regarding emails and have had them work with one exception. The range that i am pulling the emails from has blanks. The list starts in cell BD9 and goes until BD45. The macro below works great if there is no blanks, but do to people coming and going from my list i will always have blanks. The macro gets hung up with the following [If cell.Value Like "?*@?*.?*" Then] line. Is there anything i can add the the code to ignore the blanks and go on to the next cell???
Dim cell As Range
Dim strto As String
For Each cell In ThisWorkbook.Sheets("Contacts").Range("BD9:BD45")
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"
End If
Next cell
If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = strto
.Subject = Worksheets("Contacts").Range("ac18")
.Body = ""
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Dim cell As Range
Dim strto As String
For Each cell In ThisWorkbook.Sheets("Contacts").Range("BD9:BD45")
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"
End If
Next cell
If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = strto
.Subject = Worksheets("Contacts").Range("ac18")
.Body = ""
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub