An Excel Solution with One Formula for Each Sum Value
It sounds like you want the OFFSET
function. I'm going to use MATRIX()
as a stand-in for whatever function you have that is returning a matrix. If you want to show sums for the first 3 rows of that matrix, the formulas would be as follow:
=SUM(OFFSET(MATRIX(),0,0,1)
=SUM(OFFSET(MATRIX(),1,0,1)
=SUM(OFFSET(MATRIX(),2,0,1)
The format is OFFSET(Reference,Rows,Columns,[Height],[Width])
. There's a more detailed explanation of the arguments on the MS Support page but the key points is that Rows,Columns
describes how far to offset from the top-left cell in the Reference
range and Height,Width
describes how large to make the array from that offset cell. You want it to be 1 row high and the same width as the original so use 1 for Height
and just leave Width
blank as it will default to be the same width as Reference
.
An Excel Solution with One Formula Returning a Vector of Sums
This question is a duplicate of one over at Stack Overflow. If you want to return the array, the formula is:
MMULT(MATRIX(),TRANSPOSE(COLUMN(MATRIX())^0))
Note the lack of an equal sign because this formula by itself in a cell will return the #VALUE!
error. Hopefully, this is something you can work with in your application. I tested it to make sure it worked by summing those values with the array formula:
{=SUM(MMULT(MATRIX,TRANSPOSE(COLUMN(MATRIX)^0)))}
Of course, this is just a needlessly complicated version of =SUM(MATRIX())
but it worked as a test. In Excel, it also allows you to step through the calculation with the Evaluate Formula
function on the Formulas
ribbon and it'll show the array result given by MMULT
.