Hi guys, I have this macro that I found online:
This code puts the remaining fields into a Pivot table, which is what I want it to do. The problem is that it is moving it to the Values field but I want the code to place the fields into the Row Labels. Does anyone know the solution to this? Thanks.
Sub AddAllFieldsValues()
Dim pt As PivotTable
Dim iCol As Long
Dim iColEnd As Long
Set pt = ActiveSheet.PivotTables(1)
With pt
iCol = 1
iColEnd = .PivotFields.Count
For iCol = 1 To iColEnd
With .PivotFields(iCol)
If .Orientation = 0 Then
.Orientation = xlDataField
End If
End With
Next iCol
End With
End Sub
This code puts the remaining fields into a Pivot table, which is what I want it to do. The problem is that it is moving it to the Values field but I want the code to place the fields into the Row Labels. Does anyone know the solution to this? Thanks.
Sub AddAllFieldsValues()
Dim pt As PivotTable
Dim iCol As Long
Dim iColEnd As Long
Set pt = ActiveSheet.PivotTables(1)
With pt
iCol = 1
iColEnd = .PivotFields.Count
For iCol = 1 To iColEnd
With .PivotFields(iCol)
If .Orientation = 0 Then
.Orientation = xlDataField
End If
End With
Next iCol
End With
End Sub