customizing chart column color formats in code

G

Guest

I have some code that examines a set of data and generates a
x1columncluster chart. Depending on the set of data, I may have any
number of column clusters as a result. However, I currently format the
columns manually to make certain groupings a given color and another
group of columns a different color and so forth. I would like to
automate this.
Is there a way to go through each column like for x = 1 to
numberOfColumns
check group
If group = 1
set color accordingly
else set color differently
end if


Did that make sense?


TIA
 
G

Guest

I don't know exactly how you are setting up or checking your groups, but to
specify the color of a column (i.e. series) in a chart, the following line of
code specifies the complete reference to the color property of the chart
series - the () need either the index number or name of the corresponding
object:

ThisWorkbook.Sheets().ChartObjects().Chart().SeriesCollection().Interior.Color

To step through them (in a particular chart) you can do a For Each loop:
Dim ThisSeries as Series

For Each ThisSeries in
ThisWorkbook.Sheets().ChartObjects().Chart().SeriesCollection
ThisSeries.Interior.Color = ' set color here, based on your criteria
Next ThisSeries

This will color an entire series; if you need to color individual points
within that series it would be
ThisWorkbook.Sheets().ChartObjects().Chart().SeriesCollection().Points().Interior.Color
And you could step through them with a For Each again, but this time
stepping through the points instead of the series.

HTH
K Dales
 

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