Return Column Headers for Nonblank Cells in Each Excel Row
Question details
Create a spilled formula that lists the column headers corresponding to nonblank cells in each row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet has headers in one row and data beneath them; each data row needs its own list of matching headers.
- Observed behavior
- Each row should produce a comma-separated list of headers for cells that are not blank.
Confirm that your Excel version supports BYROW, FILTER, and dynamic arrays. In the example below, headers are in B1:I1 and data is in B2:I9; leave the output cells empty so the results can spill.
Use BYROW to Spill Matching Headers for Each Row
Use this formula in a supported Excel version to generate one header list per data row.
Click an empty cell outside B1:I9, such as K2. Make sure K2:K9 is clear.
In K2, enter =BYROW(B2:I9,LAMBDA(r,TEXTJOIN(", ",TRUE,FILTER(B1:I1,NOT(ISBLANK(r)),"")))) and press Enter.
Review K2:K9. Each cell lists the headers for nonblank cells in the corresponding row; an entirely blank row returns an empty result.
Edit the formula in K2 to replace B2:I9 and B1:I1 with your data and header ranges. Keep the two ranges aligned and the same width.

List Nonblank Cell Headers in WPS Spreadsheets
Use a helper column and standard formulas in WPS Spreadsheets to build a comma-separated header list for each row.
- 1. Open the worksheet: Open your workbook in WPS Spreadsheets. For this example, place headers in B1:I1 and data in B2:I9.
- 2. Build the header list: In J2, enter =IF(NOT(ISBLANK(B2)),B$1&", ","")&IF(NOT(ISBLANK(C2)),C$1&", ","")&IF(NOT(ISBLANK(D2)),D$1&", ","")&IF(NOT(ISBLANK(E2)),E$1&", ","")&IF(NOT(ISBLANK(F2)),F$1&", ","")&IF(NOT(ISBLANK(G2)),G$1&", ","")&IF(NOT(ISBLANK(H2)),H$1&", ","")&IF(NOT(ISBLANK(I2)),I$1&", ","") and press Enter.
- 3. Remove the trailing separator: In K2, enter =IF(J2="","",LEFT(J2,LEN(J2)-2)) and press Enter. K2 displays the finished list.
- 4. Fill the formulas down: Select J2:K2 and drag the fill handle down through row 9. Each row in column K will show its matching headers.

Frequently Asked Questions
What happens if an entire data row is blank?
The FILTER function returns an empty string through its if_empty argument, so the BYROW formula displays an empty result for that row.
Why does Excel show a #SPILL! error?
The output range may contain existing data. Clear the cells below the formula, such as K2:K9 in the example, and check that the formula is not inside an Excel table.
How can I exclude formulas that return an empty string?
In the Excel formula, replace NOT(ISBLANK(r)) with r<>"". This excludes both empty cells and cells whose formulas return an empty string.
Can I use a different separator between headers?
Yes. In the Excel formula, change the first TEXTJOIN argument from ", " to another separator, such as "; ".




