Mightystomp
Board Regular
- Joined
- Jan 31, 2006
- Messages
- 50
I am trying to make a macro that toggles expand/collapse pivotfield Profit Center
The problem is that pf.drilleddown returns false every time even if it has just been set to true. One can even put pf.drilleddown = true in line before and it still returns false.
I am using Excel 2013 and the pivottable is based on a table from Power Pivot.
Code:
Sub ExpandCollapse()
Dim pt As PivotTable
Dim pf As PivotField
Set pt = ActiveSheet.PivotTables("PivotSAPBO")
Set pf = pt.PivotFields("[SAPBO].[Profit Center].[Profit Center]")
If pf.DrilledDown = False Then
pf.DrilledDown = True
Else
pf.DrilledDown = False
End If
End Sub
The problem is that pf.drilleddown returns false every time even if it has just been set to true. One can even put pf.drilleddown = true in line before and it still returns false.
I am using Excel 2013 and the pivottable is based on a table from Power Pivot.