Set ActiveCell.FormulaR1C1 with variable
Posted on 2010-11-11
Is there a way to dynamically reference the row or column utilizing a variable?
ActiveCell.FormulaR1C1 = "=SUM(R[-19]C:R[-1]C)"
Instead of the [-19], I need the ability to vary the number of rows based on the number of rows currently holding data. I have a variable (integer) "r" that currrently holds the number of the last row with data, so I'd like to be able to substitute "r" for "-19". I have tried it using an integer and also a string, but can't get it to function.