Last active
April 21, 2018 17:24
-
-
Save ateneva/7b8759421a8e93e3dd75b0d702eaf513 to your computer and use it in GitHub Desktop.
How do I quickly re-arrange Pivot Table Layout in VBA?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub ShowFieldinPT() | |
Dim Wks As Worksheet | |
Dim PT As PivotTable | |
Dim PF As PivotField | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
'written by Angelina Teneva, Sept 2016 | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
For Each Wks In ActiveWorkbook.Worksheets | |
For Each PT In Wks.PivotTables | |
For Each PF In PT.PivotFields | |
Set PF = PT.PivotFields("Country") | |
If PF.Orientation <> xlHidden Then | |
'comment out as needed | |
PF.Orientation = xlPageField 'as ReportFilter | |
PF.Orientation = xlRowField 'as RowField | |
PF.Orientation = xlColumnField 'as ColumnField | |
PF.Orientation = xlDataField 'as Value Field | |
End If | |
Next PF | |
Next PT | |
Next Wks | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment