Note: The other languages of the website are Google-translated. Back to English
English English

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.

Generic Formulas



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.

Related functions

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.

Related formulas

Sum multiple columns if one criterion is met
This tutorial will guide you how to sum values in multiple columns based on the same criterion in Excel.

Sum top N values or top N values with criteria
This step-by-step tutorial demonstrates how to use the SUMPRODUCT function with the LARGE function to sum the top N values in a range and sum the top N values in a range with criteria in Excel.

Sum values based on column or both column and row
This tutorial provides different formulas based on the SUMPRODUCT function to help you sum values based on a column header, and sum values based on both column and row criteria.

Sum values in last N days based on criteria
To sum values in last N days based on specific criteria in Excel, you can apply a formula based on the SUMIF and TODAY function.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

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.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • 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.
Screen Shot of Excel (with Office Tab installed)
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations