VBA Select Case Within Data Series Loop (Colour Each data point in multi-series Bubble Chart)

bubleanalytics

Spammer
Joined
Jan 9, 2018
Messages
1
Hi. I have a multi-series Bubble Chart (each data point is part of its own data series eg. ActiveChart.FullSeriesCollection(1).Select is first bubble, ActiveChart.FullSeriesCollection(2).Select is second bubble etc.)

I want to use a SELECT CASE statement so that a data point is coloured based on its value (eg. "Average", "Median") in column 1 of an excel spreadsheet. I get NO ERRORS but I CAN NOT get the following code to work on my chart even though it is the on;y chart on my active spreadsheet:

Sub ChartFormatBubblec()
Dim myChartObject As ChartObject
Dim mySrs As Series
Dim myPts As Points


With ActiveSheet
For Each myChartObject In .ChartObjects
For Each mySrs In myChartObject.Chart.SeriesCollection
Set myPts = mySrs.Points
With mySrs
For i = 1 To myPts.Count
SegmentValue = ActiveSheet.Cells(i + 1, 1).Value
Select Case SegmentValue
Case "Average"
myPts(myPts.Count).Format.Fill.ForeColor.RGB = RGB(300, 0, 0)
Case "Upper Limit"
myPts(myPts.Count).Format.Fill.ForeColor.RGB = RGB(0, 0, 0)
Case "Lower Limit"
myPts(myPts.Count).Format.Fill.ForeColor.RGB = RGB(0, 100, 0)
Case "1 Standard Deviation"
myPts(myPts.Count).Format.Fill.ForeColor.RGB = RGB(0, 0, 100)
Case "Median"
myPts(myPts.Count).Format.Fill.ForeColor.RGB = RGB(0, 0, 100)
Case "Mode"
myPts(myPts.Count).Format.Fill.ForeColor.RGB = RGB(0, 30, 0)
End Select
Next i
End With
Next
Next
End With
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,346
Messages
6,124,417
Members
449,157
Latest member
mytux

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top