Basically I would like to create a calculated field based on certain pivotfields. I run a weekly report for each fiscal month with a plan and actual column. As weeks progress the source data grows. For example 1/4 Plan, 1/4 Actuals, 1/11 Plan, 11/Actuals, etc so the data source columns grow. The below code is what I have tried but I get an error. I have tried numerous other ways but to no avail. If anyone could help it would be appreciated.
i've also tried.
pt.calculatedfields.add "delta", "=pt.pivotfields(I).name- pt.pivotfields(i+1).name & """
pt.calculatedfields.add "delta", "='pt.pivotfields(I).name'- 'pt.pivotfields(i+1).name' & """
pt.calculatedfields.add "delta", "='pt.pivotfields(I).name' & "-" & 'pt.pivotfields(i+1).name' & """
Thanks again.
Code:
dim pt as pivottable
set pt=activesheet.pivottables("pivottable1")
fields=pt.pivotfields.count
for i= 15 to fields
if mid(pt.pivotfields(i).name,11,7)="Actuals" then
[bold]***** pt.calculatedfields.add "delta", "=pt.pivotfields(I).name & "-" & pt.pivotfields(i+1).name """[/bold]
end if
next
end sub
i've also tried.
pt.calculatedfields.add "delta", "=pt.pivotfields(I).name- pt.pivotfields(i+1).name & """
pt.calculatedfields.add "delta", "='pt.pivotfields(I).name'- 'pt.pivotfields(i+1).name' & """
pt.calculatedfields.add "delta", "='pt.pivotfields(I).name' & "-" & 'pt.pivotfields(i+1).name' & """
Thanks again.