ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a variable to add fields to a pivot table (https://www.excelbanter.com/excel-programming/392985-using-variable-add-fields-pivot-table.html)

Gwen

Using a variable to add fields to a pivot table
 
Please assist.

I have a data source that the last 3 of the 12 fields names will change each
time the pivot report is generated.
"This is part of what I have right now to create the report.
ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array("Fld1", _
"Fld2", "Fld3", "Fld4", "Fld5", "Fld6", "Fld7", "Fld8", "Fld9",
"Fld10", "Fld11", _
"Fld12")
How can I change these fields to variables?

And is it possible for my pivot to have fld1 and fld2 subtotals like:

fld3 fld4 fld5 fld6 fld7 fld8 fld9 fld10 fld11 fld12
data data 3 2 4 5 10 2 1 3
data data 1 3 2 1 1 7 4 9
fld2 sum total 4 5 6 6 11 9 5 12
fld1 grand total


Thanks



All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com