Forum

Notifications
Clear all

Change Sunburst point to match cell fill

2 Posts
2 Users
0 Reactions
166 Views
(@ochimus)
Posts: 1
New Member
Topic starter
 

Attached Cols A - E list sites that claim to have met various Standards in three areas (Pick, Pack and Stack), and Sunburst chart reflects that.

A sample of those sites are audited independently, and their cells are filled in green by the User (e.g. C4, D5, E8, etc).
If the cell is changed to a green fill, I need  the "point" in the Sunburst to change automatically as well - as shown (badly) in the image under the Sunburst chart.

Hovering over a point on the Sunburst, the Tooltip shows the Cell (e.g. hovering over 'Pick 3', the tooltip says the reference is 'Point "Pack 4" value 10'), so there must be some way to link that point to the fill of that cell?

Tried the attached Code, which identifies the "fill" without a problem, but throws a "runtimerror 13" when asked to match the Sunburst point:


Sub FILLCHECKED()

Dim Rc As Range
Dim varValues As Variant
Dim strName As String

'Find last row

With ActiveSheet

f = .Cells(.Rows.Count, "A").End(xlUp).Row
If f < 2 Then f = 2

'Fill segment if Table segment green:

With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1).Points
For Each Rc In Range("C2:C" & f)
If Rc <> "" And Rc.Interior.Color = RGB(0, 176, 80) Then

'**************Generates Runtime Error 13*******************

.Item(Rc).Format.Fill.ForeColor.RGB = Rc.Interior.Color
End If

Next

End With

With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(2).Points
For Each Rc In Range("D2:D" & f)
If Rc <> "" And Rc.Interior.Color = RGB(0, 176, 80) Then .Item(Rc).Format.Fill.ForeColor.RGB = Rc(1, 1).Interior.Color
Next

End With

With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(3).Points
For Each Rc In Range("E2:E" & f)
If Rc <> "" And Rc.Interior.Color = RGB(0, 176, 80) Then .Item(Rc).Format.Fill.ForeColor.RGB = Rc(1, 1).Interior.Color
Next

End With

End With

End Sub

All solutions, suggestions or alternatives welcome.

Ochimus

 

 
Posted : 03/05/2022 7:51 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Robert,

try this:

With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1).Points
For Each Rc In Range("C2:C" & f)
If Rc <> "" And Rc.Interior.Color = RGB(0, 176, 80) Then

'**************Generates Runtime Error 13*******************
For i = 1 To .Count
If .Item(i).DataLabel.Text = Rc.Text Then
.Item(i).Format.Fill.ForeColor.RGB = Rc.Interior.Color
Exit For
End If
Next
End If

Next

End With

.Points needs an index, will not accept Rc.Text like "Pick 3", so .Item(Rc) cannot work with the text from Rc range.

"Pick 3" is a Point(x).DataLabel, so you have to iterate through all points until you find one with a data label that matches your text.

 
Posted : 05/05/2022 12:19 am
Share: