Hi,
I'm trying to automate a pivot using VBA by taking the values in a column and adding them to the rows section of a pivot table.
I found this code below that work well for a single value:
But I need help with something like below to add all the values from a column:
I'm trying to automate a pivot using VBA by taking the values in a column and adding them to the rows section of a pivot table.
I found this code below that work well for a single value:
VBA Code:
ActiveSheet.PivotTables("PivotTable1").PivotFields("Product").Orientation = xlRowField
ActiveSheet.PivotTables("PivotTable1").PivotFields("Product").Position = 1
But I need help with something like below to add all the values from a column:
VBA Code:
Dim IntNumber As Long
Dim rngRows As Range
Dim FindMe As Range
IntNumber = 0
For Each FindMe In rngRows
ActiveSheet.PivotTables("PivotTable1").PivotFields("FindMe").Orientation = xlRowField
ActiveSheet.PivotTables("PivotTable1").PivotFields("FindMe").Position = IntNumber + 1
Next FindMe