How to Create an Excel Named Formula to Return the Last Nonempty Cell
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.

- 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.
Ensure your target row primarily contains text data. The REPT function method is specifically designed to locate text strings rather than numerical values.
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.
Navigate to the 'Formulas' tab on the Excel ribbon and click on 'Name Manager', then click 'New' to create your custom reference.
In the 'Name' box, enter a clear, space-free identifier for your formula, such as 'lastvaluecolumn'.
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.
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.

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. Open WPS Spreadsheet: Launch WPS Office and open your existing spreadsheet document containing the row data.
- 2. Access the Name Manager: Go to the 'Formulas' tab at the top of the screen and click on 'Name Manager'.
- 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. Use the Formula: Type =lastvaluecolumn into any cell in your workbook to instantly retrieve the final text value of the specified row.

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.




