Forum

Automating and Emai...
 
Notifications
Clear all

Automating and Emailing Pivot Table Reports [Upload Excel instead of PDF]

6 Posts
2 Users
0 Reactions
86 Views
(@wrangler)
Posts: 3
Active Member
Topic starter
 

Hello,

 

I just read the article "Automating and Emailing Pivot Table Reports" and it worked perfectly.

 

However, I have two requirements:

 

1. I need to upload excel file instead of PDF.

2. I need the pivot and the data behind pivot data to be inserted. Data of pivot also need to be filtered and need to show only that filtered data. 

 

I have dataset that only filtered "manager" need to see his own part. 

 

Thanks a lot for this amazing website and all your help beforehand! 

Regards

 
Posted : 13/04/2022 2:32 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Kemal,

You can attach any file you want to an email, that code works the same, just put the path to your xlsx instead of the pdf.

You cannot restrict the visible data for a specific person. Anyone can see all data, you have to send to that person only their subset of data.

 
Posted : 13/04/2022 11:43 pm
(@wrangler)
Posts: 3
Active Member
Topic starter
 

Hi Catalin, 

I appreciate your respond. However, I get "file not found" error when I simply change extension to xlsx. 

 

Regarding filtering data, I just want to filter data behind the pivot just as pivot, and copy visible cells to another sheet with that filtered pivot and send that sheet as an email. I believe this is possible.

 

Thank you!

 
Posted : 14/04/2022 2:59 am
(@catalinb)
Posts: 1937
Member Admin
 

You can't attach a file to an email without creating that file in that location, right?

Creating the pdf then attaching an xlsx (by simply changing the extension in the code) does not sound right.

Here is an example of a code that reads data from a table and creates a new file with data split into sheets:

https://www.myonlinetraininghub.com/excel-forum/vba-macros/parse-sheets-of-data-based-on-criteria-list#p23558

This updated part of code will split data into different files:

If MasterDict.Count > 0 Then
Dim NewWb As Workbook
Dim NewSh As Worksheet, Rng As Range
For Each aKey In MasterDict.Keys
Counter = UBound(MasterDict(aKey), 2)
'add new book, sheet
Set NewWb = Workbooks.Add
Dim DestFolder As String: DestFolder = ThisWorkbook.Path & Application.PathSeparator & "Exports"
If Len(Dir$(DestFolder, vbDirectory)) = 0 Then MkDir DestFolder
NewWb.SaveAs DestFolder & Application.PathSeparator & "Transformation QCHs Lates - " & aKey & Format(Date, "mm-dd-yyyy") & ".xlsx"
Set NewSh = NewWb.Worksheets.Add
NewSh.Name = CStr(aKey)
If Counter > 0 Then
Set Rng = NewSh.Range(NewSh.Cells(1), NewSh.Cells(Counter, Master.ListColumns.Count))
Rng.Value = TransposeArray(MasterDict(aKey))
Rng.Columns.AutoFit
NewSh.ListObjects.Add xlSrcRange, Rng, , xlYes
End If
NewWb.Close True
Next aKey
End If

 
Posted : 14/04/2022 3:17 am
(@wrangler)
Posts: 3
Active Member
Topic starter
 

Catalin, thank you for your respond.

 

Would it be too much to ask modify the code shared here: https://www.myonlinetraininghub.com/automating-emailing-pivot-table-reports

 

I really could not figure out exactly which part to change with the one you just shared. I will then try to figure out how to add data of pivot to shared workbook hopefully.

 

Regards

 
Posted : 14/04/2022 3:34 am
(@catalinb)
Posts: 1937
Member Admin
 

Sure, why not, here it is.
The code is emailing data tables, not pivot tables.

 
Posted : 14/04/2022 5:08 am
Share: