i want change colors of different columns on chart each of charts , have about 50 charts rather not manually.
i have looked on other forums , seen use:
for each cht in sheets("graphdata").chartobjects when run type-mismatch error.
i don't quite understand why isn't working. appreciated. thanks.
here code :
sub changestuff() dim cht chart, chtobj chartobject, wks worksheet each cht in sheets("graphdata").chartobjects cht.legend.delete cht.seriescollection(1).points(2).select selection.format.fill .visible = msotrue .forecolor.rgb = rgb(146, 208, 80) .transparency = 0 .solid end cht.seriescollection(1).points(3).select selection.format.fill .visible = msotrue .forecolor.rgb = rgb(255, 255, 0) .transparency = 0 .solid end cht.seriescollection(1).points(4).select selection.format.fill .visible = msotrue .forecolor.rgb = rgb(255, 192, 0) .transparency = 0 .solid end cht.seriescollection(1).points(5).select selection.format.fill .visible = msotrue .forecolor.rgb = rgb(255, 0, 0) .transparency = 0 .solid end next end sub
the type mismatch because items in sheets("graphdata").chartobjects chartobjects not charts. looks want top of loop
for each chtobj in sheets("graphdata").chartobjects set cht = chtobj.chart it tests got rid of mismatch error.
you can test kind of object you'll iterator starting variant or object , can change declaration.
Comments
Post a Comment