Fill Blank Excel Cells with the Next Nonblank Value in the Same Row
Question details
Find the next nonblank value to the right of a blank cell in the same row without creating a circular reference.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A row contains values across year columns, and blank positions should use the next available value to their right.
- Observed behavior
- A formula entered in the same cell it checks can create a circular reference; the desired result is the first nonblank value in the cells to its right.
Identify the source row and its last year column. The examples use A2:AG2 as the source and AH2:BM2 as an empty helper range; adjust the references if your data is elsewhere.
Use XLOOKUP in a helper range in Microsoft 365
Use this method when XLOOKUP is available and you want the first nonblank value to the right of each blank source cell.
In empty cell AH2, enter =IF(A2="",XLOOKUP(TRUE,B2:$AG2<>"",B2:$AG2,""),A2). Keep the formula outside A2:AG2 to avoid a circular reference.
Select AH2 and drag the fill handle across to BM2. These results correspond to source cells A2:AF2; each formula searches only the cells to the right of its source cell, up to AG2.
To replace the source cells with the results, copy AH2:BM2, select A2, and use Paste Special > Values. This replaces any existing formulas in A2:AF2 with their displayed values.

Use INDEX and MATCH in older versions of Excel
Use this array formula if your Excel version does not support XLOOKUP.
Find the Next Nonblank Row Value in WPS Spreadsheets
Use an INDEX and MATCH formula in a separate helper range to return the next nonblank value without referencing the formula cell itself.
- 1. Open the workbook: Open your Excel workbook in WPS Spreadsheets and identify the source row, such as A2:AG2.
- 2. Enter the formula: In empty cell AH2, enter =IF(A2="",IFERROR(INDEX(B2:$AG2,MATCH(TRUE,B2:$AG2<>"",0)),""),A2). If your version requires array entry, confirm with Ctrl+Shift+Enter.
- 3. Fill across: Drag the fill handle from AH2 through BM2 to calculate results for A2:AF2.
- 4. Paste values if needed: Copy AH2:BM2 and use Paste Special > Values at A2 if you want to replace the source cells with static results.

Frequently Asked Questions
Why does my formula create a circular reference?
A formula such as =IF(A2="",B2,A2) creates a circular reference if entered in A2 because it refers to itself. Put the formula in a separate helper cell, such as AH2.
What happens if every cell to the right is blank?
The formulas return an empty string when no nonblank value is found in the search range. The helper cell contains a formula even though it appears blank.
Can I fill the original blanks without keeping helper formulas?
Yes. Copy the completed helper range and use Paste Special > Values on the matching source range. This also replaces any existing formulas in that source range with static values.
Does the lookup skip text and return only numbers?
No. These formulas return the first nonblank value to the right, whether it is text or a number. A numeric-only search needs different criteria.




