vba - Referring to a range based on variables in excel? -


i trying set macro will, @ point, end setting cell sum of few cells. cells summed, however, variable, , based on other things (and change on each iteration of macro). have coded macro such know row cells on, column of beginning cell , column of ending cell (ie. perhaps a600 a606 summed). however, have set these column , row assignments variables, y, xstart, , xend. how have sum select these ranges, of cells purely defined variables?

set rng = "=sum(& y & xstart &, & y & xend &)" 

this initial guess?

use set when setting reference object. range.formaula take string argument , "=sum()".

sub example()      dim xstart long, xend long     dim targetrange range, sumrange range     dim y string     y = "b"      xstart = 2     xend = 100     set sumrange = range(" & y &  & xstart & ":" & y & xend)    set targetrange = range("a1")     targetrange.formula = "=sum(" & sumrange.address & ")"  end sub 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -