excel - Using variables instead of column names or numbers -


i'm trying draw chart in excel , here code

activesheet.shapes.addchart.select activechart.setsourcedata source:=range("'resulthl'!$e:$e") activechart.charttype = xlxyscattersmoothnomarkers activechart.seriescollection.newseries activechart.seriescollection(2).values = "='resulthl'!$cb$1:$cb$2520" 

this working fine i'd t know whether can assign column names or numbers variables , use in above code.

in line 2--> activechart.setsourcedata source:=range("'resulthl'!$e:$e") need assign e variable , use

also in line 5, need use integer variable instead of 2520

how do that?

i find it's easier use cells and/or resize properties bogged down in messy string concatenation business.

example:

dim rngapples range dim shtresults worksheet dim lngmaxrow long  shtresults = worksheets("sheet1")  ' define range want plot lngmaxrow = 2520 rngapples = shtresults.range("cb1").resize(lngmaxrow, 1)  activechart.seriescollection(2).values = rngapples  

alternatively, can define range follows:

lngcolnum = 56 ' or whatever cb lngmaxrow = 2520 rngapples = shtresults.range(cells(1, lngcolnum), cells(lngmaxrow, lngcolnum)) 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -