excel - Create charts using dynamic ranges -
i'm having problems using vba in excel create charts using dynamic ranges. need chart results of each of compounds each sample. both number of samples , number of compounds can vary. example of datasheet can found here.
a sample of code tried write, range has not been defined:
sub graph() dim r range dim c range dim wks worksheet set wks = activesheet ' ' graph macro ' set r = range("b2").end(xldown) set c = range("d2").end(xltoright) activesheet.shapes.addchart2(201, xlcolumnclustered).select activechart.setsourcedata source:=range("wks!$b$2:b" & r, "wks!$p$2:p" & c) ' end sub
could point me in right direction?
try sub instead:
sub graph() activesheet.shapes.addchart2(201, xlcolumnclustered).select [a1].currentregion activechart.setsourcedata source:=range(.resize(, 1).offset(, 1), .offset(, 3).resize(, .columns.count - 3)) end end sub
Comments
Post a Comment