Quick, clean, and to the point

Sum range with INDEX

Excel formula: Sum range with INDEX
Generic formula 

To sum all values in a column or row, you can use the INDEX function to retrieve the values, and the SUM function to return the sum. This technique is useful in situations where the row or column being summed is dynamic, and changes based on user input. In the example shown, the formula in H6 is:


where "data" is the named range C5:E9.


The INDEX function looks up values by position. For example, this formula retrieves the value for Acme sales in Jan:


The INDEX function has a special and non-obvious behavior: when the row number argument is supplied as zero or null, INDEX retrieves all values in the column referenced by the column number argument. Likewise, when the column number is supplied as zero or nothing, INDEX retrieves all values in the row referenced by the row number argument:

=INDEX(data,0,1) // all of column 1
=INDEX(data,1,0) // all of row 1

In the example for formula, we supply the named range "data" for array, and we pick up the column number from H2. For row number, we deliberately supply zero. This causes INDEX to retrieve all values in column 2 of "data'. The formula is solved like this:


Other calculations

You can use the same approach for other calculations by replacing SUM with AVERAGE, MAX, MIN, etc. For example, to get an average of values in the third month, you can use:


More than one column or row

To handle return more than one row or column with INDEX, see the approach described here to "dereference" INDEX.

Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.