Function Problems

How to Create an Excel Named Formula to Return the Last Nonempty Cell

Chanuka GeekiyanageChanuka Geekiyanage Nov 2, 2026 869 views

Question details

The user needs to construct a named formula to automatically retrieve the text from the furthest-right nonempty cell in a given row, specifically avoiding the use of the INDIRECT function.

How to Return the Last Nonempty Cell in a Row Using an Excel Named Formula
Product
Excel
Device & OS
not provided
Scenario
Creating a dynamic named range or formula to track and extract the latest text value entered at the end of a row dataset.
Observed behavior
The user wants a stable, non-volatile formula approach to reference the last text value, and needs to understand how to handle table size changes.
Before you start

Ensure your target row primarily contains text data. The REPT function method is specifically designed to locate text strings rather than numerical values.

Solution 1Recommended

Use LOOKUP and REPT in a Named Formula

Define a custom name using the LOOKUP function combined with REPT to dynamically find the last text string in a specified row range.

The LOOKUP function can be tricked into finding the last text entry by searching for a value that is alphabetically larger than any expected text. Using REPT("z", 99) generates a string of 99 'z's, which safely serves this purpose.

1
Open the Name Manager

Navigate to the 'Formulas' tab on the Excel ribbon and click on 'Name Manager', then click 'New' to create your custom reference.

2
Name Your Formula

In the 'Name' box, enter a clear, space-free identifier for your formula, such as 'lastvaluecolumn'.

3
Input the LOOKUP Formula

In the 'Refers to' box, carefully type =LOOKUP(REPT("z",99),Sheet1!$A1:$H1). Update the sheet name and column range to accurately match your dataset's parameters.

4
Apply the Formula to a Cell

Click 'OK' to save the definition. Click on your target cell and simply type =lastvaluecolumn, then press Enter to display the furthest-right text value.

Use LOOKUP and REPT in a Named Formula
Handling Table Expansion: If your table expands by adding new columns (for instance, beyond column H), you must edit the named formula in the Name Manager to extend the reference range (e.g., $A1:$Z1) to include the new data.
Advanced Formula Support

Find the Last Nonempty Cell Easily in WPS Spreadsheet

WPS Spreadsheet fully supports advanced array formulas, the LOOKUP function, and dynamic Name Manager features, allowing you to seamlessly track the last non-blank text cells in your rows without compatibility issues.

  1. 1. Open WPS Spreadsheet: Launch WPS Office and open your existing spreadsheet document containing the row data.
  2. 2. Access the Name Manager: Go to the 'Formulas' tab at the top of the screen and click on 'Name Manager'.
  3. 3. Define the Custom Name: Click 'New', name your rule 'lastvaluecolumn', and input =LOOKUP(REPT("z",99),Sheet1!$A1:$H1) into the reference box.
  4. 4. Use the Formula: Type =lastvaluecolumn into any cell in your workbook to instantly retrieve the final text value of the specified row.
Fully compatible with Microsoft Excel formulas including LOOKUP, REPT, and Name Manager configurations.Lightweight software with exceptionally fast calculation speeds for large datasets and complex arrays.Free and easy to use with a familiar, ribbon-style interface that requires no learning curve.
QA img-9

Frequently Asked Questions

Why does the formula use REPT("z", 99)?

The LOOKUP function attempts to find an exact match or the next largest value. When it cannot find a text string as alphabetically large as 99 'z's, it defaults to the very last text value it encounters in your specified row range. This creates a foolproof way to retrieve the furthest-right text cell.

How can I return the last nonempty cell if my row contains numbers?

To find the last numeric value instead of text, you can replace the REPT function with a massive numerical value in your LOOKUP formula. Using =LOOKUP(9.99E+307, Sheet1!$A1:$H1) will cause the function to return the last number in the range.

Can I make the formula return the last cell regardless of its data type?

Yes. You can use a formula like =LOOKUP(2, 1/(Sheet1!$A1:$H1<>""), Sheet1!$A1:$H1). This array logic divides 1 by a TRUE/FALSE condition, effectively allowing LOOKUP to find the last non-blank cell whether it contains text, numbers, or dates.