![]() |
Changing Colors in a Bar Chart
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? |
Changing Colors in a Bar Chart
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. - http://PeltierTech.com_______"EAB1977" wrote in message ps.com... 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? |
All times are GMT +1. The time now is 04:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com