Hello,

I want to delete a calculated field in a Pivot table.
I know I can't do this before setting the same calculated field as visible = false.
So I set the calculated field in object as not visible.

I tried two identical lines of code (below).
The first lines contains two variables set with the same values that you can find in the second line.

pt = "Tabella pivot3"
CampoCalcolatoToDelete = "w 49 - 06/12 CC"

ActiveSheet.PivotTables(pt).CalculatedFields(CampoCalcolatoToDelete).Delete
ActiveSheet.PivotTables("Tabella pivot3").CalculatedFields("w 49 - 06/12 CC").Delete
The second line is working fine.
The first one (with variables) it is not working.

Can anyone suggest why?

Thanks