sorting date for a simple pie chart

jayneinaccounts

New Member
Joined
Jan 24, 2007
Messages
23
Hi

I have a very simple pie chart in one of my workbooks. It is based on data 50columns by 2rows, meaning I have 50 labels/segments of pie. What I wanted the chart to do was to sort the data from largest to smallest before it creates the pie, without having to manually sort the data first. Is this possible?

Any advice would be greatly appreciated.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
The best advice I can give you is to not use a pie chart if you have that many pieces of data, as it will be meaningless. You would almost certainly be far better off with a bar chart.
For the sort, you could use an additional table using the LARGE function:
=LARGE(datarange, 1)
=LARGE(datarange, 2)
and so on, to sort in descending order.
 
Upvote 0
Maybe like this

Code:
Sub APie()
Range("A1:B50").Sort Key1:=Range("B1"), Order1:=xlAscending, _
        Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
With ActiveSheet.ChartObjects.Add(Left:=100, Width:=375, Top:=75, Height:=225)
    .Chart.SetSourceData Source:=Range("A1:B50")
    .Chart.ChartType = xlPie
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top