Excel VBA Insert a pie chart at a cell based on two percentage values

Hi

What Excel VBA code would I use to insert a pie chart starting at a certain cell
based on two values that make up 100% eg (55% and 45%)

Thanks
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Saurabh Singh TeotiaCommented:
Assuming your sheet where you want to add chart is sheet1..then you can use a simple code like this...

Sub ADDCHART()

    Sheets("Sheet1").Shapes.ADDCHART.Select
    ActiveChart.ChartType = xlPie
    ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("Sheet1!$A$1:$B$2")
End Sub

Open in new window


I'm making this chart from A1:B2
0
 
NorieVBA ExpertCommented:
Where does the data for the chart come from?
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.