I am trying to sum up entire rows by column. IE: I have Rows 4:6 that I am working with. I want it to sum A4:A6 into A7, B4:B6 into B7, C4:C6 into C7, etc, up to a predetermined Column.
I came up with a couple different solutions. The first was just manually looping through the rows and adding them up. This worked pretty well, but it felt expensive. It's entirely possible I'm trying to overengineer this step and I could just stick with the looping, but it feels messy and inefficient.
So after doing some research I developed a solution using R1C1 notation. This was great because I could assign all of the math in one easy step.
This solution does exactly what I need it to, however I do not like the fact that any changes to the file could affect the results since it is using relative references and storing the formula instead of the value from the formula.
What I would like to do is use this formula to create the result and store the value directly into the cell to avoid losing the correct information if someone else comes along and adjusts the spreadsheet.
I have seen something simliar online using Application.Evaluate and Application.ConvertFormula, but I'm not sure if that solution does what I want or what the correct syntax would be. This seems like it might work, but I'm not sure if I can apply this to an entire range like I could with the above formula.
Any help would be greatly appreciated! Also any insight into whether this is an unnecessary attempt at optimization would be great as well.
I came up with a couple different solutions. The first was just manually looping through the rows and adding them up. This worked pretty well, but it felt expensive. It's entirely possible I'm trying to overengineer this step and I could just stick with the looping, but it feels messy and inefficient.
So after doing some research I developed a solution using R1C1 notation. This was great because I could assign all of the math in one easy step.
VBA Code:
Range(Cells(last.Row + 1, 4), Cells(last.Row + 1, 11)).FormulaR1C1 = "=SUM(R[-" & last.Row - payRowArray(i) + 1 & "]C:R[-1]C)"
This solution does exactly what I need it to, however I do not like the fact that any changes to the file could affect the results since it is using relative references and storing the formula instead of the value from the formula.
What I would like to do is use this formula to create the result and store the value directly into the cell to avoid losing the correct information if someone else comes along and adjusts the spreadsheet.
I have seen something simliar online using Application.Evaluate and Application.ConvertFormula, but I'm not sure if that solution does what I want or what the correct syntax would be. This seems like it might work, but I'm not sure if I can apply this to an entire range like I could with the above formula.
Any help would be greatly appreciated! Also any insight into whether this is an unnecessary attempt at optimization would be great as well.