Find the Last Used Row Number in Excel

Published on

When working with large datasets such as sales records, purchase data, or bills of materials (BOM) in Excel, you often need to determine the last used row in a range. This is essential for data entry, structuring dynamic formulas, and formatting. Accurately identifying the last row ensures that your formulas work efficiently, especially when dealing with variable-length datasets.

In this tutorial, you’ll learn a formula-based approach to find the last used row number in Excel using the TRIMRANGE function, which is available in Microsoft 365 and later versions.

Example of how to find the last used row number in Excel

Formula to Find the Last Used Row Number in Excel

To find the last used row number in a given range, use the following formula:

=MAX(ROW(TRIMRANGE(range, 3)))

Explanation:

  • TRIMRANGE(range, 2) – Trims the range by removing empty rows from both the top and bottom.
  • ROW(TRIMRANGE(range, 2)) – Returns the row numbers of the trimmed range.
  • MAX(...) – Extracts the highest row number, which corresponds to the last used row in the dataset.

Important: Since TRIMRANGE and dynamic arrays are used, this formula works only in Microsoft 365 and Excel 2021.

Example: Finding the Last Used Row Number in a Dataset

Scenario

Assume you have a dataset containing daily sales records in the range A1:D1000. You want to determine the last used row across the entire range (not just a single column).

Formula to Use

Enter the following formula in any empty cell (e.g., F1), ensuring it is outside the range referenced in the formula.

=MAX(ROW(TRIMRANGE(A1:D1000, 3)))

How It Works

  1. TRIMRANGE(A1:D1000, 3) removes any blank rows from the start and end of the range.
  2. ROW(TRIMRANGE(A1:D1000, 3)) returns an array of row numbers that contain data.
  3. MAX(...) extracts the largest row number, giving you the last used row.

Example Output:

If your data extends to row 785, the formula will return 785 as the last used row number.

Alternative: Finding the Last Used Row in a Single Column

If you only need to find the last used row in a specific column (e.g., column A), use:

=MAX(ROW(TRIMRANGE(A:A, 3)))

This formula ensures that only column A is checked for the last used row.

FAQs

Can I use this formula for any row range, not just starting from row 1?

Yes! Your range can start and end on any row. You can also use open-ended ranges like A:D, and the formula will still work correctly.

Can I use this formula to find the last used row in a single column?

Absolutely! The formula works for both single and multi-column ranges. For a single column, just reference it directly (e.g., A:A).

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

More like this

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

Sort Each Row Individually in Excel Using a LAMBDA Formula

Sorting rows in Excel typically refers to rearranging entire datasets based on values in...

Sort by Field Labels Using the SORT and XMATCH Combo in Excel

Want to sort your Excel data by column names instead of column positions? Learn...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.