Hello all,
I have previously posted a thread about using a loop to send emails to different names which data is stored in different sheets. Here is the link. But now I have got to many names and creating different sheets for each of them names is out of the question. I was wondering would it be possible to send different emails with matching data from pivot table? This is the code I'm using right now:
Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope()
sn = Sheets("Contacts").Cells(1).CurrentRegion.Value
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
For i = 2 To UBound(sn)
ActiveWorkbook.EnvelopeVisible = True
Set Sendrng = Sheets(sn(i, 1)).Range("A1:M71")
With Sendrng
.Parent.Select
With .Parent.MailEnvelope
.Introduction = sn(i, 4)
With .Item
.To = sn(i, 2)
.Subject = sn(i, 3)
.Send
End With
End With
End With
Next
ActiveWorkbook.EnvelopeVisible = False
With Application
.Goto Sheets("Contacts").Range("A1")
.ScreenUpdating = False
.EnableEvents = False
End With
End Sub
Would it be possible to incorporate the below code into the code above so the pivot table would be filtered accordingly to contacts table?
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").CurrentPage = "AMKL"
Bookmarks