3LeggedDog
Board Regular
- Joined
- Feb 11, 2006
- Messages
- 149
Hi,
I have some VBA code (from using the Macro Recorder) that does exactly what I'd like it to. The macro looks at a particular range and generates a pie chart, and then removes the chart title. The only issue that I have with it is that the data labels in the pie chart show do not show any decimal values. Is there a quick way to modify this VBA to allow it to set the data labels to show one decimal place? For example, 39.2%, rather than 39%. The VBA is shown below -
Sub Macro13()
'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlPie
ActiveChart.ApplyLayout (1)
ActiveChart.SetSourceData Source:=Range("A1:B5")
ActiveChart.ChartTitle.Select
Selection.Delete
End Sub
Once that process is completed, I'd also like to run the following macro - which is complete and correct - to force the wedges to be particular colors. All I'm really looking to do here is to stitch the two together. (And credit for this macro goes to Jon Peltier, at http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=390 )
Sub ColorWedges()
Dim iPoint As Long, nPoint As Long
With ActiveChart.SeriesCollection(1)
For iPoint = 1 To .Points.Count
Select Case WorksheetFunction.Index(.XValues, iPoint)
Case "Customer Service"
.Points(iPoint).Interior.ColorIndex = 3 ' Red
Case "Dept Maintenance"
.Points(iPoint).Interior.ColorIndex = 4 ' Green
Case "Safety"
.Points(iPoint).Interior.ColorIndex = 5 ' Blue
Case "Reports"
.Points(iPoint).Interior.ColorIndex = 6 ' Yellow
Case "EEEE"
.Points(iPoint).Interior.ColorIndex = 7 ' Magenta
Case "FFFF"
.Points(iPoint).Interior.ColorIndex = 8 ' Cyan
Case "GGGG"
.Points(iPoint).Interior.ColorIndex = 9 ' Maroon
Case "HHHH"
.Points(iPoint).Interior.ColorIndex = 10 'Dark Green
Case "IIII"
.Points(iPoint).Interior.ColorIndex = 11 'Royal Blue
Case "JJJJ"
.Points(iPoint).Interior.ColorIndex = 12 'Vomit
Case "KKKK"
.Points(iPoint).Interior.ColorIndex = 13 'Bright Purple
Case "LLLL"
.Points(iPoint).Interior.ColorIndex = 14 'Sea Blue
End Select
Next
End With
End Sub
Thanks, as always,
3LD
I have some VBA code (from using the Macro Recorder) that does exactly what I'd like it to. The macro looks at a particular range and generates a pie chart, and then removes the chart title. The only issue that I have with it is that the data labels in the pie chart show do not show any decimal values. Is there a quick way to modify this VBA to allow it to set the data labels to show one decimal place? For example, 39.2%, rather than 39%. The VBA is shown below -
Sub Macro13()
'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlPie
ActiveChart.ApplyLayout (1)
ActiveChart.SetSourceData Source:=Range("A1:B5")
ActiveChart.ChartTitle.Select
Selection.Delete
End Sub
Once that process is completed, I'd also like to run the following macro - which is complete and correct - to force the wedges to be particular colors. All I'm really looking to do here is to stitch the two together. (And credit for this macro goes to Jon Peltier, at http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=390 )
Sub ColorWedges()
Dim iPoint As Long, nPoint As Long
With ActiveChart.SeriesCollection(1)
For iPoint = 1 To .Points.Count
Select Case WorksheetFunction.Index(.XValues, iPoint)
Case "Customer Service"
.Points(iPoint).Interior.ColorIndex = 3 ' Red
Case "Dept Maintenance"
.Points(iPoint).Interior.ColorIndex = 4 ' Green
Case "Safety"
.Points(iPoint).Interior.ColorIndex = 5 ' Blue
Case "Reports"
.Points(iPoint).Interior.ColorIndex = 6 ' Yellow
Case "EEEE"
.Points(iPoint).Interior.ColorIndex = 7 ' Magenta
Case "FFFF"
.Points(iPoint).Interior.ColorIndex = 8 ' Cyan
Case "GGGG"
.Points(iPoint).Interior.ColorIndex = 9 ' Maroon
Case "HHHH"
.Points(iPoint).Interior.ColorIndex = 10 'Dark Green
Case "IIII"
.Points(iPoint).Interior.ColorIndex = 11 'Royal Blue
Case "JJJJ"
.Points(iPoint).Interior.ColorIndex = 12 'Vomit
Case "KKKK"
.Points(iPoint).Interior.ColorIndex = 13 'Bright Purple
Case "LLLL"
.Points(iPoint).Interior.ColorIndex = 14 'Sea Blue
End Select
Next
End With
End Sub
Thanks, as always,
3LD