vba - Conditionally Coloring a Graph in Excel -



vba - Conditionally Coloring a Graph in Excel -

hi there!

i trying color graph (a task tracker) via vba, in excel. thought color "categories" color -- visually, mean making bars on each "row" particular color. i'm using next code, copied http://peltiertech.com/vba-conditional-formatting-of-charts-by-category-label/:

sub colorbycategorylabel() dim rpatterns range dim icategory long dim vcategories variant dim rcategory range set rpatterns = activesheet.range("a1:a5") activechart.seriescollection(2) vcategories = .xvalues icategory = 1 ubound(vcategories) set rcategory = rpatterns.find(what:=vcategories(icategory)) .points(icategory).format.fill.forecolor.rgb = rcategory.interior.color next end end sub

and can't figure out wrong.

basically, have series (series2), horizontal (category) axis labels consisting of integers 1-5. category determines vertical position of bar, want color each bar in series according vertical position, according color in range(a1:a5) -- code seems doing.

any suggestions, code, or perhaps, alternative way color bar graphs based on value of "horizontal (category) axis"?

thanks!

well, found reply problem stepping through it. can't imagine easiest way horizontal bar graphs according height works.

sub colorbycategorylabel() dim icategory long dim vcategories variant dim rcategory range dim curcolor double dim curcolorindex long dim curheight double curheight = 0 curcolorindex = 1 curcolor = activesheet.cells(curcolorindex + 1, 10).interior.color activesheet.chartobjects("chart 1").select activechart.seriescollection(2) vcategories = .xvalues icategory = 1 ubound(vcategories) if .points(icategory).top > curheight curcolorindex = curcolorindex + 1 curcolor = activesheet.cells(curcolorindex + 1, 10).interior.color curheight = .points(icategory).top end if .points(icategory).format.fill.forecolor.rgb = curcolor next end end sub

you need modify line

curcolor = activesheet.cells(curcolorindex+1,10).interior.color

to specify cells background color wish copy.

by way, if interested in timetracker, hosted here: https://drive.google.com/file/d/0b85fvjqdbl3luvppnmdgt1vkww8/view?usp=sharing

excel vba excel-vba

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -