I am trying to graphic with error bars in vba excel and I my code works just fine. Only instead of putting the error bars with the data in the range I have defined it puts error bars with a fixed value and I can not figure out why.
Sub meanSD()
Dim sumsht As Worksheet
Set sumsht = Worksheets("Summary")
Dim chtobj As ChartObject
Set chtobj = sumsht.ChartObjects.Add(70, 700, 600, 300)
Dim rngAmount As Range
Set rngAmount = sumsht.Range(Cells(2, 51), Cells(41, 51))
With chtobj.Chart
.ChartType = xlColumnClustered
.SetSourceData Source:=Range("Summary!$B$50:$AO$50")
.FullSeriesCollection(1).Name = "=Summary!$A$1"
.FullSeriesCollection(1).XValues = "=Summary!$B$3:$AO$4"
.FullSeriesCollection(1).HasErrorBars = True
.FullSeriesCollection(1).ErrorBars.Select
.FullSeriesCollection(1).ErrorBar Direction:=xlX, Include:=xlErrorBarIncludeBoth, Type:=xlErrorBarTypeCustom, Amount:=rngAmount, MinusValues:=rngAmount
End With
End Sub