excel pivot add all field in row code example
Example 1: excel pivot add all field in row
Sub AddAllFieldsValues()
'Update 20141112
Dim pt As PivotTable
Dim I As Long
For Each pt In ActiveSheet.PivotTables
For I = 1 To pt.PivotFields.Count
With pt.PivotFields(I)
If .Orientation = 0 Then .Orientation = xlDataField
End With
Next
Next
End Sub
Example 2: excel pivot add all field in row
Sub AddAllFieldsValues()
'Update 20141112
Dim pt As PivotTable
Dim I As Long
For Each pt In ActiveSheet.PivotTables
For I = 1 To pt.PivotFields.Count
With pt.PivotFields(I)
If .Orientation = 0 Then .Orientation = xlDataField
End With
Next
Next
End Sub