vbscript - Run time error 1004, Application defined or object defined error -
i have written vbscript code add chart in page 1 of excel source other sheet of same excel name "cl.1.1" getting above error can 1 wrong in below code.
sub dispvstime(shname) sheets("sheet1").select noofsheets = activesheet.chartobjects.count if noofsheets > 0 activesheet.chartobjects.select activesheet.chartobjects.delete end if sheets("sheet1").pictures.visible = false activesheet.shapes.addchart(1000, 420, 50, 500).select activechart.charttype = xlxyscattersmoothnomarkers activechart.setsourcedata source:=sheets("shname").range("g2:h2001") activechart.setelement (msoelementcharttitleabovechart) activechart.charttitle.text = "displacement vs time" end sub
here "shname" name of sheet data picked.
shouldn't line
activechart.setsourcedata source:=sheets("shname").range("g2:h2001")
be
activechart.setsourcedata source:=sheets(shname).range("g2:h2001")
since want use variable shname , not sheet named "shname"
hope helps!
Comments
Post a Comment