Hi,
im having trouble with my code, what im trying to achieve is to automatically select all fields change them to a sum and the format to currency GBP.
the reason for this is i have 104 columns of data and the goal is to save time.
here is what i have so far, i also need help stitching it together in one macro.
(To select all fields)
Sub AddAllFieldsValues()
'update 20161219
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
(to sum all fields)
Sub AddAllFieldsValues()
Dim pt As PivotTable
Dim pf As PivotField
Dim ws As Worksheet
Set ws = ActiveSheet
Set pt = ws.PivotTables(1)
Application.ScreenUpdating = False
pt.ManualUpdate = True
For Each pf In pt.DataFields
pf.Function = xlSum
Next pf
pt.ManualUpdate = False
Application.ScreenUpdating = True
Set pf = Nothing
Set pt = Nothing
Set ws = Nothing
End Sub
Many thanks
Rosco
im having trouble with my code, what im trying to achieve is to automatically select all fields change them to a sum and the format to currency GBP.
the reason for this is i have 104 columns of data and the goal is to save time.
here is what i have so far, i also need help stitching it together in one macro.
(To select all fields)
Sub AddAllFieldsValues()
'update 20161219
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
(to sum all fields)
Sub AddAllFieldsValues()
Dim pt As PivotTable
Dim pf As PivotField
Dim ws As Worksheet
Set ws = ActiveSheet
Set pt = ws.PivotTables(1)
Application.ScreenUpdating = False
pt.ManualUpdate = True
For Each pf In pt.DataFields
pf.Function = xlSum
Next pf
pt.ManualUpdate = False
Application.ScreenUpdating = True
Set pf = Nothing
Set pt = Nothing
Set ws = Nothing
End Sub
Many thanks
Rosco