Function Problems

How to Use an IF Formula to Add Text from the Previous Row in Excel

Amos GikundaAmos Gikunda Nov 10, 2026 869 views

Question details

The user wants to use a formula to automatically display specific text combined with data from the previous row when a certain condition is met.

How to Use an IF Formula to Add Text from the Previous Row
Product
Spreadsheet
Device & OS
not provided
Scenario
Automating data entry in a column based on a trigger text in an adjacent cell, while dynamically referencing data from the row immediately above.
Observed behavior
The target cell needs to display concatenated text from the previous row if the condition is true, or remain blank to allow for manual entry if the condition is false.
Before you start

Ensure your dataset is sorted logically so that the 'previous row' consistently contains the correct text you want to reference. Be cautious when inserting or deleting rows, as this will shift your relative cell references.

Solution 1Recommended

Use the IF Function with the Concatenate Operator (&)

This method uses a straightforward IF statement combined with the ampersand (&) symbol to pull text from the cell above when a specific condition is met, leaving the cell blank otherwise.

The IF function evaluates a logical test. By using relative references, we can ask Excel to look at the current row's condition, but fetch the text from the row above it.

1
Select the target cell

Click on cell B2 (or the first cell where you want the formula to evaluate the condition). Do not start in row 1, as there is no previous row to reference.

2
Enter the IF formula

Type the formula =IF(A2="ONO","For "&A1,"") into the formula bar.

3
Apply and copy the formula

Press Enter to apply the formula. Then, click the fill handle (the small square at the bottom right of cell B2) and drag it down to apply the formula to the rest of the column.

Use the IF Function with the Concatenate Operator (&)
Formula Breakdown: The formula checks if A2 equals "ONO". If true, it concatenates "For " with the value in A1 (the row above). If false, the double quotes "" ensure the cell remains completely blank for manual entry.
Advanced Spreadsheet Capabilities

Effortlessly Manage Complex Formulas in WPS Spreadsheet

WPS Spreadsheet offers full support for all standard Excel functions, including logical IF statements and text concatenation. You can easily process conditional text generation and automate your data entry within a highly intuitive interface.

  1. 1. Open your workbook in WPS Spreadsheet: Launch WPS Office and open your spreadsheet file containing the data.
  2. 2. Input your conditional formula: Select the target cell (e.g., B2) and type your IF formula directly into the formula bar: =IF(A2="ONO","For "&A1,"").
  3. 3. Utilize Smart Fill: Hover over the bottom-right corner of the active cell and double-click the fill handle to automatically populate the rest of the column down to your last row of data.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx, .xls, .csv).Free, lightweight, and fast to launch for handling large and complex datasets.Provides intelligent formula auto-completion and error checking to simplify logical functions.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my formula returning a #REF! error when pulling text from the row above?

This error occurs if you place the formula in the very first row (Row 1). Because the formula asks to look at the row above, Row 1 tries to reference a non-existent 'Row 0', resulting in a reference error. Always start this formula from Row 2 or below.

Can I use this formula to add text from two rows above instead of just one?

Yes. You simply need to adjust the relative reference in the formula. If your formula is in B3 and evaluates A3, to get text from two rows above, change the reference to A1. For example: =IF(A3="ONO","For "&A1,"").

How do I change the formula so it works if the cell 'contains' ONO rather than being exactly 'ONO'?

To check for a partial text match, you can nest the SEARCH and ISNUMBER functions inside your IF statement. The formula would look like this: =IF(ISNUMBER(SEARCH("ONO",A2)),"For "&A1,"").