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 Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Sort Pie Slices in Google Sheets

To sort pie slices in a pie chart, you need to sort the data...

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

Sort Column by Length of Text in Google Sheets

To sort a column by length of text, you can either use the QUERY...

More like this

Dynamic Way to Insert Blank Rows in a Table in Excel

Do you want to easily insert n number of blank rows in a table...

Insert N Empty Cells Between Values in Excel (Dynamic Array)

Do you want to space out data by inserting a specific number of empty...

How to Extract the Last N Non-Blank Rows in Excel Dynamically

You can use the following formula to extract the last N non-blank rows in...

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.