I am using the following code to dynamically fill 2 slices of a pie (there will only ever be 2 slices) which has stopped working properly.
When it stopped working the first time I delete the offending chart and rebuilt it, ran the code and it worked but then on a subsequent test it stopped working properly.
When it doesn't work, it fails to fill the second slice and fills it with the same colour as the first slice.
When I step through the code, the line to select a slice select the plot area rather than the slice and when I try to select it manually it still doesn't work.
Is this a known bug in 2010? If so, is there a work around other than dynamically deleting and rebuilding the chart.
TIA
When it stopped working the first time I delete the offending chart and rebuilt it, ran the code and it worked but then on a subsequent test it stopped working properly.
When it doesn't work, it fails to fill the second slice and fills it with the same colour as the first slice.
When I step through the code, the line to select a slice select the plot area rather than the slice and when I try to select it manually it still doesn't work.
Is this a known bug in 2010? If so, is there a work around other than dynamically deleting and rebuilding the chart.
TIA
Code:
Sub SliceFill()
Dim rngFill As Range
Dim strFill As String
Dim varPointIndex
Sheets("Assignment Dashboards Charts").Select
Set rngFill = Range("ADC_SliceFills")
ActiveSheet.ChartObjects("cht_ADCPie1").Activate
Do Until rngFill = ""
strFill = rngFill
varPointIndex = Application.Match(strFill, ActiveChart.SeriesCollection(1).XValues, 0)
If Not IsError(varPointIndex) Then
varPointIndex = Application.Match(strFill, ActiveChart.SeriesCollection(1).XValues, 0)
ActiveChart.SeriesCollection(1).Points(varPointIndex).Interior.Color = rngFill.Interior.Color
Else
End If
Set rngFill = rngFill.Offset(1, 0)
Loop
Set rngFill = Range("ADC_SliceFills")
ActiveSheet.ChartObjects("cht_ADCPie2").Activate
Do Until rngFill = ""
strFill = rngFill
varPointIndex = Application.Match(strFill, ActiveChart.SeriesCollection(1).XValues, 0)
If Not IsError(varPointIndex) Then
varPointIndex = Application.Match(strFill, ActiveChart.SeriesCollection(1).XValues, 0)
ActiveChart.SeriesCollection(1).Points(varPointIndex).Interior.Color = rngFill.Interior.Color
Else
End If
Set rngFill = rngFill.Offset(1, 0)
Loop
ActiveSheet.ChartObjects("cht_ADCPie1").Activate
ActiveChart.Legend.Select
Selection.Left = 19.971
Selection.Width = 343.523
ActiveSheet.ChartObjects("cht_ADCPie2").Activate
ActiveChart.Legend.Select
Selection.Left = 19.971
Selection.Width = 343.523
Set rngFill = Nothing
End Sub