Excel VBA - Reference chart data point by name instead of index number -



Excel VBA - Reference chart data point by name instead of index number -

i have basic gantt chart table info source, however, when name selected somewhere on sheet, table gets emptied , refilled info belongs chosen name.

there 1 info point same every name , want bar have color.

i know way reference info point:

activechart.fullseriescollection(2).points(3)

but wont work in illustration because amount of info points keeps changing , same thing not in 3rd position.

i tried this, thought throws me type mismatch error:

activechart.fullseriescollection(2).points("somestring")

is possible reference info point name in vba?

with simple gantt chart looks this:

you can alter color of point b first returning xvalue, match against name looking , set corresponding point color:

option explicit sub changepointbcolor() dim x integer dim varvalues variant dim cht chart set cht = worksheets("sheet1").chartobjects("chart 3").chart cht.seriescollection(2) varvalues = .xvalues x = lbound(varvalues) ubound(varvalues) if varvalues(x) = "b" .points(x).interior.color = rgb(140, 125, 230) end if next x end end sub

result

excel vba excel-vba excel-charts

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -