Determine if a PivotField is visible?
I set up a short macro and pivot table to try this out. I am assuming that
"Sum of Actual" means that the original column of data was labeled
"Actual", and that it has been placed as a Data Field (to sum up the
values). Making it hidden will essentially remove it from the data area of
the pivot table.
Public Sub Test()
Dim ws As Worksheet
Dim pt As PivotTable
Dim pfSumOfActual As PivotField
On Error Resume Next
Set ws = ActiveSheet
Set pt = ws.PivotTables(1)
Set pfSumOfActual = pt.PivotFields("Sum of Actual")
If pfSumOfActual Is Nothing _
Then
'Field is Hidden (not currently in the pivot table).
Else
'Field is currently visible.
pfSumOfActual.Orientation = xlHidden
End If
End Sub
--
Regards,
Bill Renaud
|