Hello Everyone,
First time posting on the board (even though I have been here a while I've never signed up until today!)
I wondered if someone could help me with (what I hope will be) a quick VBA query. I have a macro that is picking up email addresses from Column B so long as in Column C the field contains "Active". The VBA then creates an email for each email address. I would like the macro to create one email for all people who meet the criteria and their email addresses to be added to .bcc. Ideally this should look for an address in B and then stop once it gets to an empty row (but if that cant be done then I'm happy for any suggestions!)
Below is an example of my table starting from A7
[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Email Address[/TD]
[TD]Active/Inactive[/TD]
[/TR]
[TR]
[TD]User 1[/TD]
[TD]user1@madeup.co.uk[/TD]
[TD]Active[/TD]
[/TR]
[TR]
[TD]User 2[/TD]
[TD]user2@madeup.co.uk[/TD]
[TD]Inactive[/TD]
[/TR]
[TR]
[TD]User 3[/TD]
[TD]user3@madeup.co.uk[/TD]
[TD]Active[/TD]
[/TR]
</tbody>[/TABLE]
Here is my current macro:
Thank you in advance for your help!
First time posting on the board (even though I have been here a while I've never signed up until today!)
I wondered if someone could help me with (what I hope will be) a quick VBA query. I have a macro that is picking up email addresses from Column B so long as in Column C the field contains "Active". The VBA then creates an email for each email address. I would like the macro to create one email for all people who meet the criteria and their email addresses to be added to .bcc. Ideally this should look for an address in B and then stop once it gets to an empty row (but if that cant be done then I'm happy for any suggestions!)
Below is an example of my table starting from A7
[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Email Address[/TD]
[TD]Active/Inactive[/TD]
[/TR]
[TR]
[TD]User 1[/TD]
[TD]user1@madeup.co.uk[/TD]
[TD]Active[/TD]
[/TR]
[TR]
[TD]User 2[/TD]
[TD]user2@madeup.co.uk[/TD]
[TD]Inactive[/TD]
[/TR]
[TR]
[TD]User 3[/TD]
[TD]user3@madeup.co.uk[/TD]
[TD]Active[/TD]
[/TR]
</tbody>[/TABLE]
Here is my current macro:
Code:
Sub EmailActiveTaskManagers()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim ws As Worksheet
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Column("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.row, "C").Value) = "active" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.value
.BCC = " "
.Subject = "IMPORTANT - FOR YOUR ACTION"
.HTMLBody = "EMAIL TEXT"
.Display 'Or use Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Thank you in advance for your help!