Filter Pivot table by each customer and auto email invoices unpaid

whatsup

New Member
Joined
May 25, 2011
Messages
11
Attached file.

after you step into the macros. once it filters invoices unpaid by the first customer, in the pivot.

It gives an error

I was not able to resolve this.

anyone able to help me run this code please.

Objective of this macro is automate: filter on pivot for each customer, that shows invoices unpaid. then email it to the customer..and so on for each customer

thanks ,

Does not work, it gives error when reaching line

ActiveWorkbook.EnvelopeVisible = True

" Method mail envelope of object _worksheet failed"

below is the code...


Code:
Sub autoemail_customer()

Dim r As Range
Dim i As Integer


Set r = Sheets("Pivot").Cells

For i = 2 To 8

 Sheets("Pivot").Range("B1").Select
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Customer name"). _
        ClearAllFilters
    ActiveSheet.PivotTables("PivotTable1").PivotFields("Customer name"). _
        CurrentPage = Sheets("Email Contact").Range("A" & i).Value
        
ActiveWorkbook.EnvelopeVisible = True

  
With r.Parent.MailEnvelope.Item

.To = Sheets("Email Contact").Range("b" & i).Value
.CC = ""
.Subject = Sheets("Email Contact").Range("a" & i).Value & "Customer invoices : Invoices Overdue"
.Body = "Below, list of invoices that are currently overdue and unpaid"
.send

End With



Next i


End Sub
 
Last edited by a moderator:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top