M
MikeZz
Hi,
I have some VBA that makes changes to multiple Pivot fields at once to show
various data in a Pivot Chart.
Is there a clean way to have VBA sort the Pivot by say the Grand Total
Column (either reverse or ascending) so that the pivot bar chart looks like a
pareto.... tallest bars at the left of the stacked bar chart?
As an example of a simple single column ("Customer") & row ("Group") field,
I want to sort the data so that the customer with highest sales is at the
top of the list.
Here's a recording of a macro but it just seems to reference cells in the
worksheet. The problem is that if I change the colum/row fields, the
cell/column/row of the total will also change.
Range("I7").Select
Selection.Sort Key1:="R7C9", Order1:=xlAscending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Selection.Sort Key1:="R7C9", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Range("A7").Select
Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlTopToBottom
Range("B6").Select
Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlLeftToRight
Selection.Sort Order1:=xlDescending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlLeftToRight
I have some VBA that makes changes to multiple Pivot fields at once to show
various data in a Pivot Chart.
Is there a clean way to have VBA sort the Pivot by say the Grand Total
Column (either reverse or ascending) so that the pivot bar chart looks like a
pareto.... tallest bars at the left of the stacked bar chart?
As an example of a simple single column ("Customer") & row ("Group") field,
I want to sort the data so that the customer with highest sales is at the
top of the list.
Here's a recording of a macro but it just seems to reference cells in the
worksheet. The problem is that if I change the colum/row fields, the
cell/column/row of the total will also change.
Range("I7").Select
Selection.Sort Key1:="R7C9", Order1:=xlAscending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Selection.Sort Key1:="R7C9", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Range("A7").Select
Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlTopToBottom
Range("B6").Select
Selection.Sort Order1:=xlAscending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlLeftToRight
Selection.Sort Order1:=xlDescending, Type:=xlSortLabels, OrderCustom:=1, _
Orientation:=xlLeftToRight