Home > Net >  Issue with MS Excel macro adding colour to a bubbles in a bubble chart
Issue with MS Excel macro adding colour to a bubbles in a bubble chart

Time:04-27

I am using Microsoft 365 Apps for enterprise Excel and am following this tutorial: enter image description here

Sub ChangePointColour()
    Dim Cht As Chart
    Dim Ser As Series
    Dim Pt As Point
    
    'Seect the chart
    ActiveSheet.ChartObjects(1).Activate
    Set Cht = ActiveChart
    Set Ser = Cht.SeriesCollection(1)
    PointCount = Ser.Points.Count
    
    For i = 1 To PointCount
        'Get the colour from column F
        ThisColor = ActiveSheet.Cells(i   1, 6).Value
        Select Case ThisColor
            Case "Red"
                Ser.Points(i).Format.Fill.ForColor.RGB = RGB(255, 0, 0)
            Case "Green"
                Ser.Points(i).Format.Fill.ForColor.RGB = RGB(0, 255, 0)
            Case "Amber"
                Ser.Points(i).Format.Fill.ForColor.RGB = RGB(255, 191, 0)
        End Select
        
    Next i
End Sub

CodePudding user response:

ForeColor instead of ForColor.

  • Related