Open Pivot Data on a specified sheet

ranv

New Member
Joined
Jul 11, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi hoping someone can help me with a problem,

I currently have to run a monthly report which imports data from various spreadsheets and then generates a couple of pivot tables.

Once the pivots are created i apply a filter and then double click the 'grand total field' to view the data on a new sheet. . As the new sheets are inserted automatically, i cannot automate my formulas in a macro. i would like to show the 'grand-total' data on specifically named worksheets.

on my first pivot i want to be able to automate the process of double clicking on the grand total and having this data displayed on worksheet 'D'
I then want to go back into the same pivot table, filter on a different 'desktoptype' and open the grand-total data on Worksheet 'S'

part of my code to generate pivot is below: i hope someone can provide some tips on guidance on how to get this working . (hopefully my description above makes sense)

Worksheets("D_S").Activate

On Error Resume Next

ActiveSheet.PivotTables("D/S").TableRange2.Clear

LastRow = DSheet.Cells(Rows.Count, 1).End(xlUp).Row
LastCol = DSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Set PRange = DSheet.Cells(1, 1).Resize(LastRow, LastCol)

'Define Pivot Cache
Set PCache = ActiveWorkbook.PivotCaches.Create _
(SourceType:=xlDatabase, SourceData:=PRange). _
CreatePivotTable(TableDestination:=PSheet.Cells(2, 2), _
TableName:="D/S")

'Insert Blank Pivot Table
Set PTable = PCache.CreatePivotTable _
(TableDestination:=PSheet.Cells(1, 1), TableName:="D/S")

With ActiveSheet.PivotTables("D/S").PivotFields("DesktopType")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("D/S").AddDataField ActiveSheet.PivotTables( _
"D/S").PivotFields("email"), "Count of email", xlCount
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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