parkerbelt
Active Member
- Joined
- May 23, 2014
- Messages
- 377
I'm trying to use VBA to enter a simple formula into cell BM10 that gives me a 4 week forecast.
I want to take the number that the user enters(CurrentWeekNumber) and add it to RC[-54] plus 1, plus 2 and plus 3, so the formula gets the values from 4 different cells and adds them together.
Here is the code that doesn't work that I'm using:
ActiveCell.FormulaR1C1 = "=SUM(RC[-54+" & CurrentWeekNumber & "+1],RC[-54+" & CurrentWeekNumber & "+2],RC[-54+" & CurrentWeekNumber & "+3],RC[-54+" & CurrentWeekNumber & "+4])"
Here's the error that I'm getting:
Run-time error '1004':
Application-defined or object-defined error
This should be a simple one, I just can't get the syntax right.
Thanks!
I want to take the number that the user enters(CurrentWeekNumber) and add it to RC[-54] plus 1, plus 2 and plus 3, so the formula gets the values from 4 different cells and adds them together.
Here is the code that doesn't work that I'm using:
ActiveCell.FormulaR1C1 = "=SUM(RC[-54+" & CurrentWeekNumber & "+1],RC[-54+" & CurrentWeekNumber & "+2],RC[-54+" & CurrentWeekNumber & "+3],RC[-54+" & CurrentWeekNumber & "+4])"
Here's the error that I'm getting:
Run-time error '1004':
Application-defined or object-defined error
This should be a simple one, I just can't get the syntax right.
Thanks!