I'm trying to enter the summation formula into three
columns that vary in placement based on the value of num_objs. Basically, the number of grey columns in each of the three sets will equal num_objs. I want the user to be able to enter values into the grey columns in the middle section and the values of the two rightmost white columns (with '0's in them currently) will change accordingly.
My current code is below. However, I keep getting a compile error saying "Expected: end of statement".
I've been searching for a solution online for a couple days now, and I don't see how my code is different than what I've been seeing of other people using variables in their formulas.
Dim curr_sum As Integer
curr_sum = 13 + num_objs
Dim transfer_sum As Integer
transfer_sum = 13 + num_objs + num_objs + 1
Dim post_start As Integer
post_start = 13 + num_objs + 1
Dim post_sum As Integer
post_sum = 13 + num_objs + num_objs + num_objs + 2
'fill the "total" columns with the correct sums
For total_row = 6 To 99
Cells(total_row, curr_sum).FormulaR1C1 = _
"=SUM(R"&total_row&"C13:R"&total_row&"C"&curr_sum -1&")"
Cells(total_row, transfer_sum).FormulaR1C1 = "=SUM(RC[-"&num_objs&"]:RC[-1])"
Cells(total_row, post_sum).FormulaR1C1 = "=SUM(RC[-"&num_objs"]:RC[-1])"
Next total_row
Thanks for all your help.
Bookmarks