excel - Setting FormulaArray to Formula skips every other row and column -
a fast way enter formulas this:
range("e5:h10").formula = "=a1"
the column , row references adjust, example formula code enters in cell h10 "=d6".
however, doesn't work array formulas:
range("e5:h10").formulaarray = "=a1"
that puts array formula {=a1} in each of cells; no adjustments rows or columns.
of course can loop through cells , enter unique array formula in each one, isn't fast.
so tried this:
range("e5:h10").formula = "=a1" range("e5:h10").formulaarray = range("e5:h10").formula
but results surprising -- references skip every other row , every other column; example:
-- formula in f5 {=c1} instead of expected {=b1}, and
-- formula in d6 {=a3} instead of expected {=a2}, and
-- formula in h10 {=g11} instead of expected {=d6}.
wtf?? why skip rows , columns that?? btw i'm in excel 2007 sp3.
for i'm doing this, fastest way found worked:
range("e5").formulaarray = "=a1" range("e5:h10").filldown range("e5:h10").fillright
that works slower direct way be. -- why setting formulaarray property formula property skip referenced rows , columns shown above?
the a1 formula evaluated relative top left cell of range populating. a1 works fine in e5, b1 4 , left 3 e5, formula entered f5 refers cell 4 , left 3, c1. repeats other cells. simple solutions use:
range("e5:h10").formulaarray = range("e5:h10").formular1c1
since formula same every cell.
Comments
Post a Comment