Making multiple Pie Charts, one per line of data

snipescc

Board Regular
Joined
Aug 29, 2010
Messages
136
Office Version
  1. 365
Platform
  1. Windows
I have a large amount of data that I'm going to need to put into pie charts with only a day or two of turnaround, so I'd like to figure out a way to automate it.

I have data like this, with organizations and the number of actions they did in each county.
[TABLE="width: 544"]
<colgroup><col><col span="2"><col span="2"><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]County A[/TD]
[TD]County B[/TD]
[TD]County C[/TD]
[TD]County D[/TD]
[TD]County E[/TD]
[/TR]
[TR]
[TD]Organization 1[/TD]
[TD="align: right"]71[/TD]
[TD="align: right"]170[/TD]
[TD="align: right"]172[/TD]
[TD="align: right"]126[/TD]
[TD="align: right"]113[/TD]
[/TR]
[TR]
[TD]Organization 2[/TD]
[TD="align: right"]155[/TD]
[TD="align: right"]98[/TD]
[TD="align: right"]52[/TD]
[TD="align: right"]51[/TD]
[TD="align: right"]142[/TD]
[/TR]
[TR]
[TD]Organization 3[/TD]
[TD="align: right"]133[/TD]
[TD="align: right"]152[/TD]
[TD="align: right"]151[/TD]
[TD="align: right"]114[/TD]
[TD="align: right"]91[/TD]
[/TR]
[TR]
[TD]Organization 4[/TD]
[TD="align: right"]104[/TD]
[TD="align: right"]138[/TD]
[TD="align: right"]143[/TD]
[TD="align: right"]153[/TD]
[TD="align: right"]93[/TD]
[/TR]
[TR]
[TD]Organization 5[/TD]
[TD="align: right"]188[/TD]
[TD="align: right"]72[/TD]
[TD="align: right"]77[/TD]
[TD="align: right"]103[/TD]
[TD="align: right"]122[/TD]
[/TR]
[TR]
[TD]Organization 6[/TD]
[TD="align: right"]183[/TD]
[TD="align: right"]72[/TD]
[TD="align: right"]93[/TD]
[TD="align: right"]176[/TD]
[TD="align: right"]127[/TD]
[/TR]
[TR]
[TD]Organization 7[/TD]
[TD="align: right"]64[/TD]
[TD="align: right"]88[/TD]
[TD="align: right"]96[/TD]
[TD="align: right"]170[/TD]
[TD="align: right"]84[/TD]
[/TR]
[TR]
[TD]Organization 8[/TD]
[TD="align: right"]163[/TD]
[TD="align: right"]163[/TD]
[TD="align: right"]127[/TD]
[TD="align: right"]75[/TD]
[TD="align: right"]138[/TD]
[/TR]
</tbody>[/TABLE]

I'll want a Pie chart for each organization with a breakdown by county. If I can get it to work, I may do something similar with data other than county, such as demographics. I have a couple dozen organizations, which means I may have 70-100 charts requested, depending on what my clients want to look at. If it helps, the data will likely start out in a pivot table.

Any ideas?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This looks to be working, just change Sheet2 where needed. I'm assuming the above table starts in column A, row 1.

Code:
Sub AddPies()


Dim rownum As Long


rownum = 2


Do Until Cells(rownum, 1).Value = ""
    ActiveSheet.Shapes.AddChart2(251, xlPie).Select
    ActiveChart.SetSourceData Source:=Range("Sheet2!$A$1:$F$1,Sheet2!$A$" & rownum & ":$F$" & rownum)
rownum = rownum + 1
Loop


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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