sourabh_ajmera
New Member
- Joined
- Jul 17, 2014
- Messages
- 36
Hello Everybody,
I am stuck at a problem that I been trying to solve for almost a day now. My problem is to remove a specific calculated field from the pivot table.
I know we cannot hide the field and I do not want it gone forever as I need it somewhere else so I was surfing through different sites and I stumbled upon this code. This code deletes all the calculated field which I do not want it to do.
My pivot tables contain 3 calculated fields and I want to hide/remove one field only (name of the field in pivot table : "Excess")
Can you please help me out to figure a way to hide this one specific calculated field
I am using Excel 2010
Thanks a ton in advance!
I am stuck at a problem that I been trying to solve for almost a day now. My problem is to remove a specific calculated field from the pivot table.
I know we cannot hide the field and I do not want it gone forever as I need it somewhere else so I was surfing through different sites and I stumbled upon this code. This code deletes all the calculated field which I do not want it to do.
Code:
Sub test()
Sub RemoveCalculatedFields()
Dim pt As PivotTable
Dim pf As PivotField
Dim pfNew As PivotField
Dim strSource As String
Dim strFormula As String
Set pt = ActiveSheet.PivotTables("TDPivotTable")
For Each pf In pt.CalculatedFields
strSource = pf.SourceName
strFormula = pf.Formula
pf.Delete
Set pfNew = pt.CalculatedFields.Add(strSource, strFormula)
Next pf
End Sub
My pivot tables contain 3 calculated fields and I want to hide/remove one field only (name of the field in pivot table : "Excess")
Can you please help me out to figure a way to hide this one specific calculated field
I am using Excel 2010
Thanks a ton in advance!