Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • How to Create One and Two Variable Data Tables in Excel
  • Working With Tables in Excel
  • Create Scatter Chart in Excel
  • How To Remove Duplicates In Excel Column Or Row?
  • How to create a Histogram in Excel

References

  • How to use Excel MATCH Function
  • Excel Advanced Lookup using Index and Match Functions
  • How to get first row number in range in Excel
  • Extract data with helper column in Excel
  • Two-column Lookup in Excel

Data Validations

  • Excel Data validation with conditional list
  • Prevent invalid data entering in specific cells
  • Data validation must not exist in list
  • Excel Data validation exists in list
  • Excel Data validation allow uppercase only

How to get last row in mixed data with blanks in Excel

by

To get the last relative position (i.e. last row, last column) for mixed data that may contain empty cells, you can use the MATCH function as described below.

Note: this is an array formula and must be entered with Control+Shift+Enter.

Formula

{=MATCH(2,1/(range<>""))}

Explanation

In the example shown, the formula in E5 is:

{=MATCH(2,1/(B4:B10<>""))}

Last *relative* position, not row on worksheet

When constructing more advanced formulas, it’s often necessary to figure out the last location of data in a list. Depending on the data, this could be the last row with data, the last column with data, or the intersection of both. We want the last *relative position* inside a given range not the row number on the worksheet:

Worked Example:   How to get last row in numeric data in Excel

How this formula works

This formula uses the MATCH function configured to find the position of the last non-empty cell in a range.

Worked Example:   Even and Odd function in Excel

Working from the inside out, the lookup array inside MATCH is constructed like this:

=1/(B4:B10<>""))
=1/{TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;FALSE}
={1;#DIV/0!;1;#DIV/0!;1;1;#DIV/0!}

Note: all values in the array are either 1 or the #DIV/0! error.

MATCH is then set to match the value 2 in “approximate match mode”, by omitting the 3rd argument is omitted.

Worked Example:   Calculate total hours that fall between two times in Excel

Because the lookup value of 2 will never be found, MATCH will always find the last 1 in the lookup array, which corresponds to the last non-empty cell.

This approach will work with any kind of data, including numbers, text, dates, etc. It also works with null text strings that are returned by formulas like this:

=IF(A1<100,"")

Post navigation

Previous Post:

How to generate random date between two dates in Excel

Next Post:

Popularly Used Excel Functions and their examples

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

Logical Functions

  • SWITCH function example in Excel
  • How to use Excel AND Function
  • How to use IFS function in Excel
  • IFNA function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel XOR Function

Date Time

  • Add years to date in Excel
  • Add months to date in Excel
  • WEEKNUM function: Description, Usage, Syntax, Examples and Explanation
  • Calculate retirement date in Excel
  • How to calculate next day of week in Excel

Grouping

  • Group numbers at uneven intervals in Excel
  • Running count group by n size in Excel
  • Categorize text with keywords in Excel
  • Calculate conditional mode with criteria in Excel
  • How to randomly assign people to groups in Excel

General

  • How to fill cell ranges with random number from fixed set of options in Excel
  • Advanced Number Formats in Excel
  • How to create dynamic named range with INDEX in Excel
  • Count cells that contain errors in Excel
  • Find, Trace and Correct Errors in Excel Formulas using ‘Formula Auditing’
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning