Link to home
Create AccountLog in
Avatar of BryanKipp
BryanKipp

asked on

Set ActiveCell.FormulaR1C1 with variable

Is there a way to dynamically reference the row or column utilizing a variable?

Example:

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.
ASKER CERTIFIED SOLUTION
Avatar of jppinto
jppinto
Flag of Portugal image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of BryanKipp
BryanKipp

ASKER

That works! Thanks!!