excel - How to plot graphs on their corresponding sheet? -
i taking data multiple spreadsheets , plotting them on chart, each of respective spreadsheets. want data spreadsheet1 plot graph on spreadsheet1. currently, code plots of graphs on last sheet, graphs sheets 1,2,3, etc plotted on last sheet. unsure how fix new vba. recorded macro code plot data.
here plotting code:
for j = 1 size 'creates chart activesheet.shapes.addchart2(240, xlxyscatter).select activesheet.shapes("chart 1").incrementleft 696.75 activesheet.shapes("chart 1").incrementtop -81.75 activesheet.shapes("chart 1").scalewidth 1.3333333333, msofalse, _ msoscalefromtopleft activesheet.shapes("chart 1").scaleheight 1.6909722222, msofalse, _ msoscalefromtopleft application.cutcopymode = false application.cutcopymode = false application.cutcopymode = false application.cutcopymode = false application.cutcopymode = false application.cutcopymode = false activechart.seriescollection.newseries activechart.fullseriescollection(1).name = "=""length , depth data""" activechart.fullseriescollection(1).xvalues = worksheets("case " & overview(j, 1)).range("$r$10:$r$6000") activechart.fullseriescollection(1).values = worksheets("case " & overview(j, 1)).range("$s$10:$s$6000") activechart.seriescollection.newseries activechart.fullseriescollection(2).name = "=""b31g maop""" activechart.fullseriescollection(2).xvalues = worksheets("case " & overview(j, 1)).range("$c$10:$c$159") activechart.fullseriescollection(2).values = worksheets("case " & overview(j, 1)).range("$i$10:$i$159") activechart.seriescollection.newseries activechart.fullseriescollection(3).name = "=""b31g 1.25sf""" activechart.fullseriescollection(3).xvalues = worksheets("case " & overview(j, 1)).range("$c$10:$c$159") activechart.fullseriescollection(3).values = worksheets("case " & overview(j, 1)).range("$j$10:$j$159") activechart.seriescollection.newseries activechart.fullseriescollection(4).name = "=""b31g 1.39sf""" activechart.fullseriescollection(4).xvalues = worksheets("case " & overview(j, 1)).range("$c$10:$c$159") activechart.fullseriescollection(4).values = worksheets("case " & overview(j, 1)).range("$p$10:$p$159") activewindow.smallscroll down:=-126 activewindow.scrollcolumn = 3 activewindow.scrollcolumn = 4 activewindow.scrollcolumn = 5 activewindow.scrollcolumn = 6 activewindow.scrollcolumn = 7 activewindow.scrollcolumn = 8 activewindow.smallscroll down:=6 range("w32").select activesheet.shapes.addchart2(240, xlxyscatter).select activesheet.shapes("chart 2").incrementleft 311.25 activesheet.shapes("chart 2").incrementtop 213 activewindow.smallscroll down:=18 range("ad46:ad47").select activesheet.chartobjects("chart 2").activate activesheet.chartobjects("chart 2").activate activesheet.shapes("chart 2").scalewidth 1.3145833333, msofalse, _ msoscalefromtopleft activesheet.shapes("chart 2").scaleheight 1.4930555556, msofalse, _ msoscalefromtopleft activesheet.chartobjects("chart 2").activate application.cutcopymode = false application.cutcopymode = false application.cutcopymode = false activechart.seriescollection.newseries activechart.fullseriescollection(1).name = "=""length , depth data""" activechart.fullseriescollection(1).xvalues = worksheets("case " & overview(j, 1)).range("$r$10:$r$6000") activechart.fullseriescollection(1).values = worksheets("case " & overview(j, 1)).range("$s$10:$s$6000") activechart.seriescollection.newseries activechart.fullseriescollection(2).name = "=""mb31g maop""" activechart.fullseriescollection(2).xvalues = worksheets("case " & overview(j, 1)).range("$c$10:$c$159") activechart.fullseriescollection(2).values = worksheets("case " & overview(j, 1)).range("$n$10:$n$159") activechart.seriescollection.newseries activechart.fullseriescollection(3).name = "=""mb31g 1.25sf""" activechart.fullseriescollection(3).xvalues = worksheets("case " & overview(j, 1)).range("$c$10:$c$159") activechart.fullseriescollection(3).values = worksheets("case " & overview(j, 1)).range("$o$10:$o$159") activechart.seriescollection.newseries activechart.fullseriescollection(4).name = "=""b31g 1.39sf""" activechart.fullseriescollection(4).xvalues = worksheets("case " & overview(j, 1)).range("$c$10:$c$159") activechart.fullseriescollection(4).values = worksheets("case " & overview(j, 1)).range("$p$10:$p$159") activewindow.smallscroll down:=-117 activesheet.chartobjects("chart 1").activate activechart.plotarea.select activechart.setelement (msoelementcharttitleabovechart) activewindow.smallscroll down:=9 activechart.charttitle.text = "b31g burst curve" selection.format.textframe2.textrange.characters.text = "b31g burst curve" selection.format.textframe2.textrange.characters(1, 16).paragraphformat .textdirection = msotextdirectionlefttoright .alignment = msoaligncenter end with selection.format.textframe2.textrange.characters(1, 16).font .baselineoffset = 0 .bold = msofalse .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.rgb = rgb(89, 89, 89) .fill.transparency = 0 .fill.solid .size = 14 .italic = msofalse .kerning = 12 .name = "+mn-lt" .underlinestyle = msonounderline .spacing = 0 .strike = msonostrike end activesheet.chartobjects("chart 2").activate activechart.axes(xlvalue).majorgridlines.select activechart.setelement (msoelementcharttitleabovechart) activewindow.smallscroll down:=-12 activechart.charttitle.text = "b31g burst curve" selection.format.textframe2.textrange.characters.text = "b31g burst curve" selection.format.textframe2.textrange.characters(1, 16).paragraphformat .textdirection = msotextdirectionlefttoright .alignment = msoaligncenter end with selection.format.textframe2.textrange.characters(1, 4).font .baselineoffset = 0 .bold = msofalse .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.rgb = rgb(89, 89, 89) .fill.transparency = 0 .fill.solid .size = 14 .italic = msofalse .kerning = 12 .name = "+mn-lt" .underlinestyle = msonounderline .spacing = 0 .strike = msonostrike end with selection.format.textframe2.textrange.characters(5, 12).font .baselineoffset = 0 .bold = msofalse .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.rgb = rgb(89, 89, 89) .fill.transparency = 0 .fill.solid .size = 14 .italic = msofalse .kerning = 12 .name = "+mn-lt" .underlinestyle = msonounderline .spacing = 0 .strike = msonostrike end activesheet.chartobjects("chart 1").activate activechart.charttitle.select application.commandbars("format object").visible = false activechart.charttitle.text = "mb31g burst curve" selection.format.textframe2.textrange.characters.text = "mb31g burst curve" selection.format.textframe2.textrange.characters(1, 17).paragraphformat .textdirection = msotextdirectionlefttoright .alignment = msoaligncenter end with selection.format.textframe2.textrange.characters(1, 17).font .baselineoffset = 0 .bold = msofalse .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.rgb = rgb(89, 89, 89) .fill.transparency = 0 .fill.solid .size = 14 .italic = msofalse .kerning = 12 .name = "+mn-lt" .underlinestyle = msonounderline .spacing = 0 .strike = msonostrike end next j
i in different way. quick fix wall of code provided adding beginning right after loop starts:
for j = 1 size 'creates chart worksheets("case " & overview(j, 1)).activate 'rest of code same '... next j
you should read question , answers:
Comments
Post a Comment