Sum the last N columns in Excel
To sum values in the last n columns, normally you may need to calculate the sum of each column and then add up the results to get the final sum. This tutorial provides a formula based on the INDEX function to help you easily get it done.
How to sum values in the last n columns in Excel?
As shown in the example below, there is a monthly sales table, to sum only the sales in the last 3 months (Apr, May and Jun), you can follow the steps below.
Data_range: A range of cells where we want to sum the last n columns;
N: A number represents the number of last columns you will sum from the data_range.
How to use this formula?
Select a formula, copy or enter the formula below and press the Enter key to get the result.
Note: In this case, cell B13 contains the number representing the last N columns, you can directly type this number into the formula and enclose it in double quotation marks as follows.
Explanation of the formula
COLUMNS(C5:H10): The COLUMNS function returns the number of columns in the reference C5:E4. Here you will get 6 columns;
INDEX(C5:H10,0,6-(B13-1)) = INDEX(C5:H10,0,6-(3-1)) = INDEX(C5:H10,0,4): The syntaxt of the INDEX function: INDEX(array, row_num, [column_num]). Here the row_number is set to 0, so the INDEX function returns the reference for the entire fourth column: $F$5:$F$10;
COLUMNS(C5:H11): The COLUMNS function returns the number of columns in the reference C5:E4. Here you will get 6 columns;
INDEX(C5:H10,0,6)): Here the INDEX function returns the reference for the entire sixth column: $H$5:$H$10;
SUM($F$5:$F$10:$H$5:$H$10) = SUM($F$5:$H$10): The SUM function then sums all numbers in range F5:H10 and returns the total amount: 8580.
Excel SUM function
The Excel SUM function adds values.
Excel INDEX function
The Excel INDEX function returns the displayed value based on a given position from a range or an array.
Excel COLUMNS function
The Excel COLUMNS function returns the total number of columns in a given array or reference.
The Best Office Productivity Tools
Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings
300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save
80% time for you.
- Designed for
1500 work scenarios, helps you solve
80% Excel problems.
- Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
- Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by
50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.