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

Lookup and Reference Examples

  • How to use Excel COLUMN Function
  • How to use Excel INDIRECT Function
  • How to get address of last cell in range in Excel
  • How to retrieve first match between two ranges in Excel
  • Basic INDEX MATCH approximate in Excel

Data Analysis Examples

  • How To Remove Duplicates In Excel Column Or Row?
  • Working With Tables in Excel
  • How to Create One and Two Variable Data Tables in Excel
  • How to calculate correlation coefficient Correlation in Excel
  • How to Use Solver Tool in Excel

Data Validation Examples

  • Excel Data validation unique values only
  • Excel Data validation specific characters only
  • Excel Data validation exists in list
  • Excel Data validation number multiple 100
  • Excel Data validation allow uppercase only

How to get last column number in range in Excel

by

You can get the last column in a range with a formula based on the COLUMN function. See example below:

Formula

=MIN(COLUMN(range))+COLUMNS(range)-1

Note: When given a single cell reference, the COLUMN function returns the column number for that reference. However, when given a range that contains multiple columns, the COLUMN function will return an array that contains all column numbers for the range.

Explanation

In the example shown, the formula in cell F5 is:

=MIN(COLUMN(data))+COLUMNS(data)-1

where data is a named range for B5:D10

Worked Example:   INDEX and MATCH descending order in Excel

How this formula works

If you want only the first column number, you can use the MIN function to extract just the first column number, which will be the lowest number in the array.

Once we have the first column, we can just add the total columns in the range and subtract 1, to get the last column number.

Worked Example:   Calculate date overlap in days in Excel

Index version

Instead of MIN, you can also use INDEX to get the last row number:

=COLUMN(INDEX(data,1,1))+COLUMNS(data)-1

This is possibly a bit faster for large ranges, since INDEX just supplied a single cell to COLUMN.

Simple version

When a formula returns an array result, Excel will display the first item in the array if the formula is entered in a single cell. This means that in practice, you can often just use a simplified version of the formula:

=COLUMN(data)+COLUMNS(data)-1

But be aware that this will return an array for a multi-column range.

Worked Example:   How to calculate average last N values in a table in Excel

Inside formulas, it’s sometimes necessary to make sure you are dealing with only one item, and not an array. In that case, you’ll want to use the full version above.

Post navigation

Previous Post:

How to get relative row numbers in a range in Excel

Next Post:

How to get last row in mixed data with blanks 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
  • How to strip numeric characters from cell in Excel
  • How to count number of characters of text in a cell in Excel
  • Remove file extension from filename in Excel
  • How to extract substring in Excel
  • NUMBERVALUE function: Description, Usage, Syntax, Examples and Explanation
  • YEARFRAC function: Description, Usage, Syntax, Examples and Explanation
  • Add days exclude certain days of week in Excel
  • Display Days until expiration date in Excel
  • Get age from birthday in Excel
  • Convert Excel time to Unix time in Excel
  • Calculate cumulative loan interest in Excel
  • PRICEDISC function: Description, Usage, Syntax, Examples and Explanation
  • NPER function: Description, Usage, Syntax, Examples and Explanation
  • PRICEMAT function: Description, Usage, Syntax, Examples and Explanation
  • COUPDAYS function: Description, Usage, Syntax, Examples and Explanation
Acronyms, Abbreviations, Initialism & What They Stand For
© 2021 xlsoffice. All Rights Reserved | Teal Smiles