series.ErrorBar(Direction, Include, Type, [Amount], [MinusValues])


For 2-D chart types, adds error bars to the series. Causes an error for 3-D chart types.




An xlErrorBarDirection constant that specifies the axis direction for the bar. Possible settings are xlX or xlY.


An xlErrorBarInclude constant that specifies the type of bar. Possible settings are xlErrorBarIncludeBoth, xlErrorBarIncludeNone, xlErrorBarIncludeMinusValues, or xlErrorBarIncludePlusValues.


An xlErrorBarType constant that specifies the calculation used to size the bar. Possible settings are xlErrorBarTypeCustom, xlErrorBarTypePercent, xlErrorBarTypeStError, xlErrorBarTypeFixedValue, or xlErrorBarTypeStDev.


If Type is xlErrorBarTypeCustom, the positive value of the bar.


If Type is xlErrorBarTypeCustom, the negative value of the bar.

The following code adds error bars to the first series of the active chart:

Sub AddErrorBars(  )
    Dim chrt As Chart, sr As Series
    ' Get a chart.
    Set chrt = ActiveChart
    ' Use 2-D chart type.
    chrt.ChartType = xlLineMarkers
    ' Get first series
    Set sr = chrt.SeriesCollection(1)
    ' Add error bars.
    sr.ErrorBar xlY, xlErrorBarIncludeBoth, xlErrorBarTypeStError
End Sub

Get Programming Excel with VBA and .NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.