ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Colouring error bars in a chart (https://www.excelbanter.com/excel-programming/369374-colouring-error-bars-chart.html)

Graham Whitehead

Colouring error bars in a chart
 
Hi, I have draw a chart which has three series on it. I want to colour the
error based on the series they belong to. When I record the process I get:

ActiveSheet.ChartObjects("Chart 278").Activate
ActiveChart.SeriesCollection(1).ErrorBars.Select
With Selection.Border
.LineStyle = xlContinuous
.ColorIndex = 3
.Weight = xlThin
End With
Selection.EndStyle = xlNoCap

So I have tried to work this into something which might work:

With chtChart
.SeriesCollection(1).ErrorBars.Select
With Selection.Border
.LineStyle = xlContinuous
.ColorIndex = 3
.Weight = xlThin
End With
End With

But this is giving me an error. Can anyone see what is wrong?



Bernie Deitrick

Colouring error bars in a chart
 
Graham,

This should work: you need to work with the chartobject's chart, a step that isn't recorded by the
macro recorder.

With chtChart.Chart
With .SeriesCollection(1).ErrorBars
With .Border
.LineStyle = xlContinuous
.ColorIndex = 3
.Weight = xlThin
End With
End With
End With

HTH,
Bernie
MS Excel MVP


"Graham Whitehead" wrote in message
...
Hi, I have draw a chart which has three series on it. I want to colour the error based on the
series they belong to. When I record the process I get:

ActiveSheet.ChartObjects("Chart 278").Activate
ActiveChart.SeriesCollection(1).ErrorBars.Select
With Selection.Border
.LineStyle = xlContinuous
.ColorIndex = 3
.Weight = xlThin
End With
Selection.EndStyle = xlNoCap

So I have tried to work this into something which might work:

With chtChart
.SeriesCollection(1).ErrorBars.Select
With Selection.Border
.LineStyle = xlContinuous
.ColorIndex = 3
.Weight = xlThin
End With
End With

But this is giving me an error. Can anyone see what is wrong?






All times are GMT +1. The time now is 04:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com