Skip to content
xlsoffice. All Rights Reserved
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Lookup and Reference Examples

  • Find Closest Match in Excel Using INDEX, MATCH, ABS and MIN functions
  • MATCH function: Description, Usage, Syntax, Examples and Explanation
  • Lookup entire row in Excel
  • CHOOSE function: Description, Usage, Syntax, Examples and Explanation
  • How to get address of last cell in range in Excel

Data Analysis Examples

  • How to calculate correlation coefficient Correlation in Excel
  • Working With Tables in Excel
  • How to Sort by Color in Excel
  • Subtotal function in Excel
  • How to sum a total in multiple Excel tables

Data Validation Examples

  • Excel Data validation no punctuation
  • Excel Data validation exists in list
  • Excel Data validation with conditional list
  • Excel Data validation unique values only
  • Excel Data validation don’t exceed total

Sum last n columns in Excel

by

This tutorial shows how to Sum last n columns in Excel using the example below;

Formula

=SUM(INDEX(data,0,COLUMNS(data)-(n-1)):INDEX(data,0,COLUMNS(data)))

Explanation

To sum the last n columns in a table of data (i.e. last 3 columns, last 4 columns, etc.) you can use a formula based on the INDEX function. In the example shown, the formula in K5:

=SUM(INDEX(data,0,COLUMNS(data)-(K4-1)):
INDEX(data,0,COLUMNS(data)))

where “data” is the named range C5:H8

Worked Example:   Get first non-blank value in a list in Excel

How this formula works

The key to understanding this formula is to realize that the INDEX function can be used to return a reference to entire rows and entire columns.

To generate a reference to the “last n columns” in a table, we build a reference in two parts, joined by the range operator. To get a reference to the left column, we use:

INDEX(data,0,COLUMNS(data)-(K4-1))

Since data contains 6 columns, and K4 contains 3, this simplifies to:

INDEX(data,0,4) // all of column 4

To get a reference to the right column in the range, we use:

INDEX(data,0,COLUMNS(data))

Which returns a reference to column 6 of the named range “data”, since the COLUMN function returns 6:

INDEX(data,0,6) // all of column 6

Together, the two INDEX functions return a reference to columns 4 through 6 in the data (i.e. F5:H8), which resolve to an array of values inside the SUM function:

SUM({15,14,10;9,12,12;7,9,9;12,13,13})

The SUM function then calculates and returns the sum, 135.

Worked Example:   Extract all partial matches in Excel
Worked Example:   Get cell content at given row and column in Excel

Post navigation

Previous Post:

Sum if ends with in Excel

Next Post:

Sum if equal to one of many things in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others
  • PHONETIC function: Description, Usage, Syntax, Examples and Explanation
  • How to abbreviate names or words in Excel
  • RIGHT, RIGHTB functions: Description, Usage, Syntax, Examples and Explanation
  • Remove unwanted characters in Excel
  • How to check if cell contains number in Excel
  • Calculate total hours that fall between two times in Excel
  • SECOND function: Description, Usage, Syntax, Examples and Explanation
  • Calculate days remaining in Excel
  • Calculate number of hours between two times in Excel
  • Extract date from a date and time in Excel
  • Example of Future value of annuity in Excel
  • Calculate payment for a loan in Excel
  • PMT, RATE, NPER, PV and FV Financial Functions in Excel
  • IPMT function: Description, Usage, Syntax, Examples and Explanation
  • COUPNUM function: Description, Usage, Syntax, Examples and Explanation
Acronyms, Abbreviations, Initialism & What They Stand For
© 2021 xlsoffice. All Rights Reserved | Teal Smiles