Change the Point Color in chart excel VBA

后端 未结 2 653
情书的邮戳
情书的邮戳 2020-12-03 23:01

I have this chart in which if any point in graphs exceeds specific limit then its color should change.

\"enter

相关标签:
2条回答
  • 2020-12-03 23:12

    Let's take another approach, which does not require any code.

    Assume your data is in columns A (sequence number or time) and B value, starting in A2 and B2, since your labels are in A1 and B1. We'll add a series to the chart that includes any deviant values from column B. This series will draw a marker in front of any deviant points so the original point will still be present, and instead of reformatting this point the new series displays a point.

    In cell C1, enter "Deviant".

    In Cell C2, enter a formula that detects a deviant point, something like:

    =IF(AND(B2>upperlimit,B2

    This puts the value into column C if column B exceeds upper and lower limits, otherwise it puts #N/A into column C, #N/A will not result in a plotted point.

    Copy the data in column C, select the chart, and Paste Special as a new series. Format this series to have no line and whatever glaring marker you want to use to indicate an out of control point.

    0 讨论(0)
  • 2020-12-03 23:24

    Using: ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart1").Chart.SeriesCollection(1)

    Color of each point is .Points(PointNumber).Interior.Color

    The number of points you have to cycle though is .Points.Count

    The value of each point is .Points(PointNumber).Value

    colors of the markers themselves (Applies only to line, scatter, and radar charts):

    .Points(PointNumber).MarkerBackgroundColor = RGB(0,255,0)    ' green
    .Points(PointNumber).MarkerForegroundColor = RGB(255,0,0)    ' red
    .Points(PointNumber).MarkerStyle = xlMarkerStyleCircle ' change the shape
    
    0 讨论(0)
提交回复
热议问题