i want write macro when ran create basic scatter plot data. issue running is, want color data points dark green if >25, light green if >0 , blue otherwise. other problem having want put custom data label on data points. custom label come column , display number in cell if greater 0.
sub plot_data() range("m3:m132,r3:r132").select range("r132").activate activesheet.shapes.addchart2(240, xlxyscatter).select activechart.setsourcedata source:=range("'cond #2 data'!$m$3:$m$132,'cond #2 data'!$r$3:$r$132") activechart.cleartomatchstyle activechart.chartstyle = 248 activesheet.shapes("chart 2").incrementleft -1.5 activesheet.shapes("chart 2").incrementtop -23.25 lastrow = cells(rows.count, "a").end(xlup).row = 2 lastrow if cells(i, 40) > 0 'custom label= cells(i,40) end if next set cht = activesheet.chartobjects(1).chart set s = cht.seriescollection(1) vals = s.values x = worksheetfunction.max(lbound(vals), 8) ubound(vals) dim flag boolean flag = true = 0 7 if vals(x - i) > 25 'do nothing else flag = false end if next if flag = true s.points(x) .format.line.forecolor.rgb = rgb(255, 0, 0) end end if next x end sub
Comments
Post a Comment