RC sum formula references

Cullen

New Member
Joined
Jan 13, 2009
Messages
47
I need to sum from a specific point(d14) down a column various lengths depending on a user input. If the user inputs say 5, I need something along the lines of:

ActiveCell.FormulaR1C1 = "=SUM(R14C:R[num]C)"

The 'num' is defined from a userform and could be any number they put in.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Thank for your reply. This works from the relative reference of the cell that displays the sum, but I really want to move down 'num' cells from d14, not the cell with the formula. I don't have a clue on the syntax for that. Something like:

ActiveCell.FormulaR1C1 = "=SUM(R14C:R14[-" & num & "]C)"

How do you keep the static reference of R14 in the second half of the range minus the num inputted Thanks!
 
Upvote 0
Is it?

Code:
ActiveCell.FormulaR1C1 = "=SUM(R14C:R[" & 14 - num & "]C)"
 
Upvote 0
Wonderful. I had to tweak it a little bit and create another number range from the cells below what I wanted and subtract them and the 3 blank cells above the cell with the formula. Works perfect. Thank you so much for your help.

ActiveCell.FormulaR1C1 = "=SUM(R14C:R[" & -3 - Enum & "]C)"
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,937
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top