spill-the-beans
Board Regular
- Joined
- Feb 7, 2013
- Messages
- 52
Hello all,
I'm trying to make a macro that creates my graphs for me, and part of this is adding custom error bars to each bar. I recorded a macro as a basis, and the relevant code it gives me is below. In my worksheet, I have custom standard errors already calculated on row 19 from columns B to F. The errors will always be in these cells across the graphs I want the macro for, but when I run the macro excel recorded for me, it cannot run the code it just created, saying there is and object variable not set, and I think that might be the range.
Is there a way to add in to the macro the range B19:F19 where I want it to look for the custom error values? Any help on this would be appreciated.
Sub test()
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).HasErrorBars = True
ActiveChart.SeriesCollection(1).ErrorBars.Select
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:=xlBoth, _
Type:=xlCustom, Amount:=0
Application.CutCopyMode = False
ActiveChart.SeriesCollection(1).ErrorBars.Select
End Sub
I'm trying to make a macro that creates my graphs for me, and part of this is adding custom error bars to each bar. I recorded a macro as a basis, and the relevant code it gives me is below. In my worksheet, I have custom standard errors already calculated on row 19 from columns B to F. The errors will always be in these cells across the graphs I want the macro for, but when I run the macro excel recorded for me, it cannot run the code it just created, saying there is and object variable not set, and I think that might be the range.
Is there a way to add in to the macro the range B19:F19 where I want it to look for the custom error values? Any help on this would be appreciated.
Sub test()
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).HasErrorBars = True
ActiveChart.SeriesCollection(1).ErrorBars.Select
ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:=xlBoth, _
Type:=xlCustom, Amount:=0
Application.CutCopyMode = False
ActiveChart.SeriesCollection(1).ErrorBars.Select
End Sub