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
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