ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   customizing chart column color formats in code (https://www.excelbanter.com/excel-programming/325862-customizing-chart-column-color-formats-code.html)

Papa Jonah

customizing chart column color formats in code
 
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


K Dales[_2_]

customizing chart column color formats in code
 
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().Serie sCollection().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().Serie sCollection
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().Serie sCollection().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

"Papa Jonah" wrote:

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



All times are GMT +1. The time now is 01:51 PM.

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