Charts : Error Bars thru VBA

  • Hi


    I am having a issue with respect to adding error bars to each data point in a series collection. Error Propogates in Time. And my chart is Time Vs Independent variable in XY Scatter Chart Sub Type One. Error on each data point is bothe positive and negative. Both the values are same.


    Chart is made from data in columns A and B. Column A has time in seconds, Column B has independent variable, lets say X. Column C has the error corresponding to each data point. Now this error needs to be represented on each data point using VBA. Can anyone be kind enough to help me out in this.


    Thanks


    Ram P

    Ram P

  • Hi Ram P,


    Some slightly modified code generated by using the record macro.

    Code
    With ActiveChart.SeriesCollection(1)
            .ErrorBar Direction:=xlX, Include:=xlBoth, _
            Type:=xlCustom, Amount:="=Sheet1!R1C3:R10C3", MinusValues:= _
            "=Sheet1!R1C3:R10C3"
            .ErrorBar Direction:=xlY, Include:=xlBoth, _
            Type:=xlCustom, Amount:="=Sheet1!R1C3:R10C3", MinusValues:= _
            "=Sheet1!R1C3:R10C3"
        End With


    The xy chart data series is based on data in range A1:B10. The x and y error bars are based on C1:C10.
    It uses the Custom +- values to set a error bar for each point in the series.


    Hopefully this is what you were after. If not then post back.


    Cheers
    Andy

    [h4]Cheers
    Andy
    [/h4]

  • Andy


    Thanks for your reply.


    My issue comes with respect to Amount and Minus values syntax.
    If I use errorx = "C2:C10" and If I use Amount:= = errorx and the same syntax for minus values, I get a error. Why do you think is this happening?


    Thanks


    Ram P

    Ram P

  • Looks like the range reference needs to be in R1C1 format.


    Try this revised code.


    Cheers
    Andy

    [h4]Cheers
    Andy
    [/h4]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!