Change Default Colors in Excel 2010 Chart -
i have workbook generates charts on fly depending on sheet selected, source of data. 2 of series lines, 2 of series bar charts values above , below 1 of line series.
i colors of bar chart positive values green, , negative values red. no matter how many variations have tried, when charts generated, default standard colors (burnt orange , aqua blue.)
after chart generated, if edit series properties directly, have no problems changing fill colors red , green.
my code:
activesheet.shapes.addchart.select application.activechart.parent.name = "chart1" activesheet.chartobjects("chart1").activate activechart.plotvisibleonly = false activechart.axes(xlvalue).select activechart.axes(xlvalue).minimumscale = valuemin - 0.1 activechart.axes(xlvalue).maximumscale = valuemax + 0.1 activechart.seriescollection(1).select 'negative series activechart.seriescollection(1).charttype = xlcolumnclustered selection.format.fill .visible = msotrue .forecolor.rgb = rgb(255, 0, 0) 'red .transparency = 0 .solid end activechart.seriescollection(2).select 'positive series activechart.seriescollection(2).charttype = xlcolumnclustered selection.format.fill .visible = msotrue .forecolor.rgb = rgb(0, 176, 80) 'green .transparency = 0 .solid end activechart.seriescollection("3").select selection.format.line .visible = msotrue .forecolor.rgb = rgb(255, 255, 0) 'yellow .transparency = 0 end activechart.seriescollection(4).select 'signal selection.format.line .visible = msotrue .forecolor.rgb = rgb(255, 51, 204) 'pink .transparency = 0 end
any ideas how beat default colors , use ones chosen? thanks.
i bit lazy write code. therefore providing pseudo code (untested). may test , use @ own discretion... run code right after generation of charts. user not notice changes @ backend - if disable screen updating @ beginning , enable @ end. don't see chart generation code. wrote 1 after generation based on question.
option explicit public sub coluremeplusminus() dim ws worksheet dim cht chartobject dim srs series dim integer dim pcred integer 'if intend use rgb, use long dim ncgreen integer '--change per own sheet set ws = activeworkbook.sheets("sheet1") pcred = 4 ncgreen = 3 each cht in ws.chartobjects each srs in cht.chart.seriescollection srs.fill .solid '--do honours end next next end sub
colour credits peltier.
update
updating per op's comment:
changing excel workbook's colour theme , how change default colors excel uses chart series.
Comments
Post a Comment