Excel guide · 4 min read
How to find the first non-blank value in Excel
=XLOOKUP(TRUE,B2:G2<>"",B2:G2). B2:G2<>"" marks each filled cell TRUE, and XLOOKUP returns the value at the first TRUE. In older Excel, use =INDEX(B2:G2,MATCH(TRUE,INDEX(B2:G2<>"",0),0)). Point the last range at the header row to get the column name instead.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Product | Jan | Feb | Mar | Apr | May | Jun | Date | Meter reading | |
| 2 | Oat bars | 340 | 410 | 385 | 460 | Nov 2, 2026 | ||||
| 3 | Trail mix | 0 | 0 | 125 | 210 | 260 | Nov 3, 2026 | |||
| 4 | Protein balls | n/a | n/a | 95 | 140 | 175 | 190 | Nov 4, 2026 | 48213 | |
| 5 | Seed crackers | 180 | Nov 5, 2026 | 48260 | ||||||
| 6 | Granola cups | Nov 6, 2026 | ||||||||
| 7 | Rice cakes | 520 | 495 | 610 | 580 | 555 | 600 | Nov 7, 2026 | 48342 |
Download this sheet as an Excel practice file (.xlsx)
XLOOKUP(TRUE, range<>"") in Excel 365
The sheet tracks monthly unit sales for snack products that launched at different times, so each row starts with gaps. B2:G2<>"" turns the Oat bars row into FALSE, FALSE, TRUE, TRUE, TRUE, TRUE. XLOOKUP looks for TRUE in that list and, like any XLOOKUP, stops at the first match from the left.
Write it in H2 and fill down to get every product's first figure. XLOOKUP is in Excel 365 and Excel 2021 and later. The same pattern works down a column: =XLOOKUP(TRUE,C2:C7<>"",A2:A7) returns the first product with anything in the Feb column, Protein balls.
Result: 340
340, the Oat bars' first month of sales.
Return the header: the first month with sales
Often the value is not what you want; you want to know when. Keep the same test and point the return range at the header row. The two ranges must be the same width, B to G in both.
For a missing row, use XLOOKUP's fourth argument. Granola cups has no sales at all, so a plain XLOOKUP returns #N/A, while =XLOOKUP(TRUE,B6:G6<>"",B1:G1,"Not launched") shows Not launched.
Result: Mar
Mar: the first month with a figure for Oat bars.
Older Excel: INDEX and MATCH(TRUE)
MATCH(TRUE,B2:G2<>"",0) finds the position of the first filled cell, 3 here. In Excel 2019 and older, a comparison over a range inside MATCH needs Ctrl+Shift+Enter. Wrapping it in INDEX(...,0) makes Excel handle the array itself, so a normal Enter works.
Swap the first INDEX range for B1:G1 to return the month, and wrap the whole thing in IFERROR for rows that are empty: =IFERROR(INDEX(B1:G1,MATCH(TRUE,INDEX(B6:G6<>"",0),0)),"Not launched").
Result: 340
340 again, in any version of Excel.
First number only, or first non-zero
"Not blank" is not always what you mean. Protein balls has n/a typed in Jan and Feb, so the <>"" test returns n/a. Test for numbers with ISNUMBER and you get the first real sales figure, 95 in Mar.
Trail mix was listed in January with 0 sales. Its first non-blank value is that 0 (Jan). For the first month with real sales, test <>0 instead: =XLOOKUP(TRUE,B3:G3<>0,B1:G1) returns Apr, 125 units. An empty cell counts as 0 in this comparison, so blanks are skipped too.
Text breaks both shortcuts. On the Protein balls row, <>0 lands on n/a again (Jan), and so does >0, because Excel ranks text above every number when it compares. When a row can hold text, combine the tests: =XLOOKUP(1,ISNUMBER(B4:G4)*(B4:G4<>0),B1:G1) returns Mar.
Result: 95
95: the n/a cells are text, so ISNUMBER skips them. In older Excel use =INDEX(B4:G4,MATCH(TRUE,INDEX(ISNUMBER(B4:G4),0),0)).
Cells that look empty but are not
Seed crackers' Jan and Feb cells hold a formula that returns "", left over from a template. They look empty. The <>"" test treats them as blank and correctly returns 180 in Jun. ISBLANK does not: ISBLANK(B5) is FALSE because the cell has a formula, so =XLOOKUP(TRUE,NOT(ISBLANK(B5:G5)),B1:G1) wrongly says Jan. COUNTA counts them too, 3 cells for this row. Use <>"" rather than ISBLANK when formulas are involved.
A space is the other trap. The meter log in I:J has a space typed in the 3 Nov cell, so =XLOOKUP(TRUE,J2:J7<>"",I2:I7) returns 3 Nov, a day with no reading. Trim before testing: LEN(TRIM(...))>0 ignores cells that only hold spaces. For a column of readings, ISNUMBER(J2:J7) works just as well and gives the same 4 Nov.
Result: Nov 4, 2026
4 Nov 2026 (once formatted as a date), the first day with a real reading of 48,213.
Common mistakes
Using ISBLANK on formula results
A formula that returns "" is not blank to ISBLANK or COUNTA. Test with range<>"" instead.
Return range a different size from the test
XLOOKUP(TRUE,B2:G2<>"",B1:H1) returns #VALUE!. Keep both ranges the same width, B to G.
Pressing Enter on MATCH(TRUE,range<>"",0) in Excel 2019
Without Ctrl+Shift+Enter, older Excel does not evaluate the comparison for every cell, so the result is an error or wrong. Wrap the test in INDEX(...,0) so plain Enter works.
Text placeholders counted as the first value
n/a, - or TBC are not blank. Use ISNUMBER when you want the first number.
FAQ
How do I find the first non-blank cell in a column?
Use the vertical version: =XLOOKUP(TRUE,A2:A100<>"",A2:A100). In older Excel, =INDEX(A2:A100,MATCH(TRUE,INDEX(A2:A100<>"",0),0)). To jump there by hand, select the top cell and press Ctrl+Down Arrow (if the top cell is empty).
How do I get the column header of the first value in a row?
Return the header row instead of the data row: =XLOOKUP(TRUE,B2:G2<>"",$B$1:$G$1). Lock the header row with $ before you fill down.
How do I find the last non-blank value instead?
Add search_mode -1 to search from the end: =XLOOKUP(TRUE,B2:G2<>"",B2:G2,,0,-1) returns 460, the Oat bars' June figure. The lookup-last-value guide covers older-Excel versions.
How do I get the row number of the first non-blank cell?
MATCH(TRUE,INDEX(A2:A100<>"",0),0) gives the position inside the range. Add 1 for a range that starts on row 2 to get the sheet row number.
Functions used
XLOOKUPModern lookup in any directionINDEXValue at a positionMATCHPosition of a valueISNUMBERIs it a number?ISBLANKIs the cell empty?IFERRORFallback when a formula errorsLENLength of textTRIMRemoves extra spacesCOUNTACounts non-empty cells
Related guides
- How to find the last value in a column in Excel
- How to check if a cell is blank in Excel
- How to return the column header of the max value in Excel
- How to use INDEX MATCH in Excel
- XLOOKUP not working: how to fix #N/A and wrong results
- VLOOKUP returns 0 instead of blank: how to fix it
- How to convert one column into multiple columns in Excel
Updated