excel - Quickly Creating Graph from Pivot Table -
excel - Quickly Creating Graph from Pivot Table -
i have next code:
private sub pivgraphmaker1(byval shtnm string, byval src1 string, byval chrtnm string) application.statusbar = "making graph 1." sheets(shtnm).select range("o1").select activesheet.shapes.addchart.select activechart.charttype = xlcolumnclustered activechart.setsourcedata source:=range(src1) activechart.parent.name = chrtnm activechart.legend.select selection.delete activesheet.chartobjects(chrtnm).activate activechart.seriescollection(1).select selection.format.fill.visible = msofalse activechart.seriescollection(1).applydatalabels activechart.seriescollection(1).datalabels.select selection.position = xllabelpositioninsideend activechart.chartarea.select activechart.setelement (msoelementcharttitleabovechart) activechart.charttitle.text = "downtime fault message" selection.format.textframe2.textrange.characters.text = _ "downtime fault message" selection.format.textframe2.textrange.characters(1, 25).paragraphformat .textdirection = msotextdirectionlefttoright .alignment = msoaligncenter end selection.format.textframe2.textrange.characters(1, 17).font .baselineoffset = 0 .bold = msotrue .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.rgb = rgb(0, 0, 0) .fill.transparency = 0 .fill.solid .size = 18 .italic = msofalse .kerning = 12 .name = "+mn-lt" .underlinestyle = msonounderline .strike = msonostrike end activechart.chartarea.select activechart.setelement (msoelementprimaryvalueaxistitlerotated) activechart.axes(xlvalue, xlprimary).axistitle.text = "duration in minutes" selection.format.textframe2.textrange.characters.text = "duration in minutes" selection.format.textframe2.textrange.characters(1, 19).paragraphformat .textdirection = msotextdirectionlefttoright .alignment = msoaligncenter end selection.format.textframe2.textrange.characters(1, 19).font .baselineoffset = 0 .bold = msotrue .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.rgb = rgb(0, 0, 0) .fill.transparency = 0 .fill.solid .size = 10 .italic = msofalse .kerning = 12 .name = "+mn-lt" .underlinestyle = msonounderline .strike = msonostrike end activechart.chartarea.select activechart.charttitle.text = shtnm & " downtime fault message" activechart.chartarea.select activechart.location where:=xllocationasnewsheet activesheet.name = shtnm & " faults" application.printcommunication = false activechart.pagesetup .leftheader = "" .centerheader = "" .rightheader = "" .leftfooter = "" .centerfooter = "" .rightfooter = "" .leftmargin = application.inchestopoints(0.7) .rightmargin = application.inchestopoints(0.7) .topmargin = application.inchestopoints(0.75) .bottommargin = application.inchestopoints(0.75) .headermargin = application.inchestopoints(0.3) .footermargin = application.inchestopoints(0.3) .chartsize = xlscreensize .printquality = 600 .centerhorizontally = false .centervertically = false .orientation = xllandscape .draft = false .oddandevenpagesheaderfooter = false .differentfirstpageheaderfooter = false .evenpage.leftheader.text = "" .evenpage.centerheader.text = "" .evenpage.rightheader.text = "" .evenpage.leftfooter.text = "" .evenpage.centerfooter.text = "" .evenpage.rightfooter.text = "" .firstpage.leftheader.text = "" .firstpage.centerheader.text = "" .firstpage.rightheader.text = "" .firstpage.leftfooter.text = "" .firstpage.centerfooter.text = "" .firstpage.rightfooter.text = "" .papersize = xlpapertabloid .firstpagenumber = xlautomatic .blackandwhite = false .zoom = 100 end application.printcommunication = true end sub
the code work. question - lines necessary? that, there can speed code (will cutting out unnecessary lines help)?
to reply couple comments know come - computer indeed slow , underpowered, notice little changes in terms of run-time speed. have things screenupdating , event disabled.
let me know can do!
something (hair code):
private sub pivgraphmaker1(byval shtnm string, byval src1 string, byval chrtnm string) dim cht excel.chart application.statusbar = "making graph 1." sheets(shtnm).select range(src1).select set cht = charts.add cht .charttype = xlcolumnclustered .setsourcedata source:=range(src1) .name = shtnm & " faults" .haslegend = false .seriescollection(1) .format.fill.visible = msofalse .applydatalabels .datalabels.position = xllabelpositioninsideend end .setelement msoelementcharttitleabovechart .charttitle .text = shtnm & " downtime fault message" .format.textframe2.textrange.characters.paragraphformat .textdirection = msotextdirectionlefttoright .alignment = msoaligncenter end .format.textframe2.textrange.characters(1, 17).font .bold = msotrue .size = 18 .kerning = 12 end end .setelement msoelementprimaryvalueaxistitlerotated .axes(xlvalue, xlprimary).axistitle .text = "duration in minutes" .format.textframe2.textrange.characters(1, 19) .paragraphformat .font .bold = msotrue .size = 10 .kerning = 12 end end end application.printcommunication = false .pagesetup .orientation = xllandscape .papersize = xlpapertabloid end application.printcommunication = true end application.statusbar = false end sub
excel excel-vba
Comments
Post a Comment