I have done some manual testing for the website where I have 3 different test results on Desktop, Tablet and Mobile for a single test case. Now I want to represent all of my test results into a Pie Chart where it will show the total number of Pass, Fail and Partial test case results. Attached image is the example how I am representing this in the Excel.
Asked
Active
Viewed 3,424 times
-3
-
1So far no question has been asked, and there's no connection to programming. Have you finished? – Tony M Aug 06 '17 at 03:01
-
Yes, this is it! I need some help with excel. I want to represent the total %age of Pass results and %age of fail results in chart form. Please let me know if you require further information. – Paramveer Aug 06 '17 at 03:17
-
I have tried inserting it with the normal Pie chart function and also assigned the colour value to its cells too. But the graph is coming out blank. – Paramveer Aug 06 '17 at 03:28
-
2show your code and some sample data and you're more likely to get help. – Tony M Aug 06 '17 at 04:27
1 Answers
0
Here's some code to get you started. It will produce the pie chart shown here as long as you put the data in A1:F2
. Notice that two of the sections are colored: for windows pass (solid red) and windows fail (gradient red). You could do the same to the other categories, of course, by extending what I've started for you here.
Sub pie()
Dim r As Range, chObj As ChartObject, pt1 As Point, pt2 As Point
Set r = ActiveSheet.Range("A1:F2")
Set chObj = ActiveSheet.ChartObjects.Add(Left:=100, Width:=375, Top:=75, Height:=225)
With chObj
.Chart.SetSourceData Source:=r
.Chart.ChartType = xlPie
Set pt1 = .Chart.FullSeriesCollection(1).Points(1)
Set pt2 = .Chart.FullSeriesCollection(1).Points(2)
End With
With pt1.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = vbRed 'RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
With pt2.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = vbRed 'RGB(255, 0, 0)
.TwoColorGradient msoGradientDiagonalUp, 1
.Transparency = 0
End With
chObj.Chart.HasLegend = True
chObj.Chart.Legend.Height = 100
End Sub

Tony M
- 1,694
- 2
- 17
- 33