ve 90% of my VBA code written, just need to add the following. My macro pretty much runs and If Statement and if a certain condition applies, it will email it to a certain address. What I need it to do is to run the if statement, and if it meets the certain condition to email it to a list of 4-5 emails (maybe even more) which is in the same workbook but a different tab entitled "Email List".
You can ignore the top part, this is what I'm currently working on.
This is the updated code. Please advise as there are 8 sections so how will I transfer the Email code you came up with for the next 7? Thanks in advance man, really appreciate all your help.
Sub Send_Range()
Dim row As Long
Dim col As Long
Dim rCell As Range
Dim SendTo As String
Dim i As Long
row = Sheets("Email List").UsedRange.Rows.Count
col = Sheets("Email List").UsedRange.Columns.Count
If Not IsEmpty(Range("B4")) Then
With Sheets("Email List")
For Each rCell In .Range(.Cells(1, 1), .Cells(1, col))
If rCell.Value <> "" Then
For i = 3 To row
If .Cells(i, rCell.Column).Value <> "" Then
SendTo = SendTo & .Cells(i, rCell.Column + 1).Value & ";"
End If
Next
End If
Next
End With
End If
If IsEmpty(Range("B4")) Then
Else
ActiveSheet.Range("a3", ActiveSheet.Range("e3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = SendTo
.Item.Subject = "Allocations - Barclays"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
row = Sheets("Email List").UsedRange.Rows.Count
col = Sheets("Email List").UsedRange.Columns.Count
If Not IsEmpty(Range("B4")) Then
With Sheets("Email List")
For Each rCell In .Range(.Cells(1, 1), .Cells(1, col))
If rCell.Value <> "" Then
For i = 3 To row
If .Cells(i, rCell.Column).Value <> "" Then
SendTo = SendTo & .Cells(i, rCell.Column + 1).Value & ";"
End If
Next
End If
Next
End With
End If
If IsEmpty(Range("H4")) Then
Else
ActiveSheet.Range("G3", ActiveSheet.Range("K3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - BNP"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
If IsEmpty(Range("N4")) Then
Else
ActiveSheet.Range("M3", ActiveSheet.Range("Q3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - CITINY"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
If IsEmpty(Range("T4")) Then
Else
ActiveSheet.Range("S3", ActiveSheet.Range("W3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - CSFB"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
If IsEmpty(Range("Z4")) Then
Else
ActiveSheet.Range("Y3", ActiveSheet.Range("AC3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - DB"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
If IsEmpty(Range("AF4")) Then
Else
ActiveSheet.Range("AE3", ActiveSheet.Range("AI3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - JPM"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
If IsEmpty(Range("AL4")) Then
Else
ActiveSheet.Range("AK3", ActiveSheet.Range("AO3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - MS"& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
If IsEmpty(Range("AR4")) Then
Else
ActiveSheet.Range("AQ3", ActiveSheet.Range("AU3").End(xlDown)).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "alulla@bluemountaincapital.com"& "; alulla92@outlook.com"
.Item.Subject = "Allocations - "& Format(Date, " mm/dd/yyyy")
.Item.Send
End With
End If
End Sub