Excel VBA - loop to fill up ranges with formulas referencing to other ranges -
i have 2 worksheets (sht1, sht2) both having similar size ranges , i'd need refer formulas sht2 sth1.
example: on sht2 add formulas range i10:k11 link sht1 range b2:d3 next on sht2 add formulas range i20:k21 link sht1 range b6:d7 , on long there ranges
there hundreds of these ranges on both sheet separate distances each other , there other stuff between ranges can't populate whole sheets. distances between ranges on sht1 constant on sht2, different each other.
what best way populate range on sht2 formulas sht1? should use integer in cells , move integer known distance between loops?
contrary comment, maths behind stagger may easier figure out range.offset property. .offset providing starting point, range.resize property reshapes target area.
sub staggerlink() dim r long, sht1 worksheet set sht1 = worksheets("sht1") worksheets("sht2") r = 0 99 .cells(10, 9).resize(2, 3).offset(r * 10, 0).formula = _ chr(61) & sht1.cells(2, 2).offset(r * 4, 0).address(false, false, external:=true) next r end end sub
you've provided no scope project other 'hundreds of these ranges' ran down 100 times. additionally, provided no sample or description of 'formula' other has 'link sht1' formula provided.
Comments
Post a Comment