Changing Colors in a Bar Chart

E

EAB1977

Hi guys,

I have a bar chart that has 3 bars in a chart. I am using a 2D
Clustered Column. I need for each bar to have a seperate color.

Name FSR QC CQA
Leola 2 8 0

The color for the three? Using Late Binding, as I can't use Early
Binding since others are using different versions of Excel (2002 and
2003).

Select Case .ActiveCell.Value
Case "QC"
.Sheets("Chart1").Select
.ActiveChart.SeriesCollection(x).Select
.Selection.Interior.ColorIndex = 19
Case "FSR"
.Sheets("Chart1").Select
.ActiveChart.SeriesCollection(x).Select
.Selection.Interior.ColorIndex = 18
Case "CQA"
.Sheets("Chart1").Select
.ActiveChart.SeriesCollection(x).Select
.Selection.Interior.ColorIndex = 17
Case Else
'Do nothing
End Select

Is this possible?
 
J

Jon Peltier

If you want to color points (bars) based on the category, try this sub:

Sub ColorPoints()
Dim iPoint As Long, nPoint As Long
With ActiveChart.SeriesCollection(1)
For iPoint = 1 To .Points.Count
Select Case WorksheetFunction.Index(.XValues, iPoint)
Case "AAAA"
.Points(iPoint).Interior.ColorIndex = 6 ' Yellow
Case "BBBB"
.Points(iPoint).Interior.ColorIndex = 5 ' Blue
Case "CCCC"
.Points(iPoint).Interior.ColorIndex = 3 ' Red
Case "DDDD"
.Points(iPoint).Interior.ColorIndex = 13 ' Purple
Case "EEEE"
.Points(iPoint).Interior.ColorIndex = 46 ' Orange
Case "FFFF"
.Points(iPoint).Interior.ColorIndex = 4 ' Green
Case "GGGG"
.Points(iPoint).Interior.ColorIndex = 8 ' Cyan
End Select
Next
End With
End Sub
If instead you ate coloring based on series name, try this:Sub ColorSeries()
With ActiveChart.SeriesCollection(1)
Select Case .Name Case "AAAA"
.Interior.ColorIndex = 6 ' Yellow
Case "BBBB"
.Interior.ColorIndex = 5 ' Blue
Case "CCCC"
.Interior.ColorIndex = 3 ' Red
Case "DDDD"
.Interior.ColorIndex = 13 ' Purple
Case "EEEE"
.Interior.ColorIndex = 46 ' Orange
Case "FFFF"
.Interior.ColorIndex = 4 ' Green
Case "GGGG"
.Interior.ColorIndex = 8 ' Cyan
End Select
End With
End Sub
- Jon-------Jon Peltier, Microsoft Excel MVPTutorials and Custom
SolutionsPeltier Technical Services, Inc. -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top