Manually tracking which projects qualify for specific budgets is a tedious process for financial analysts. While teams typically rely on standard funding sources like federal allocations, state subsidies, and private endowments, consolidating this data manually leads to costly reporting errors.
Automating this with Excel grants users the ability to dynamically aggregate active funding types. Under the stipulation that your data headers remain uniform, you can deploy a robust formula solution. Leading finance teams utilize TEXTJOIN paired with IF as the primary method to consolidate these active sources. Below, we will demonstrate the exact formula structure to concatenate header names for non-blank cells.
When working with large datasets in Excel, you often encounter matrices where columns represent specific categories, tasks, attributes, or products, and rows represent individual records. A common challenge is summarizing these matrices. For instance, if you have a checklist of skills or assigned tasks across multiple columns, you might want a single summary column that lists every header where the corresponding cell is not blank.
In older versions of Excel, achieving this required tedious, nested formulas or complex VBA macros. However, with modern Excel functions like TEXTJOIN and FILTER, you can accomplish this task with a single, elegant formula. In this guide, we will explore the best methods to concatenate header names if a cell is not blank, ranging from the most modern solutions to legacy workarounds.
Before diving into the formulas, let's visualize the target layout. Imagine we have a matrix tracking project assignments for team members. The columns represent different projects, and a checkmark or any character in the row indicates that the person is assigned to that project.
| Name (A) | Project Alpha (B) | Project Beta (C) | Project Gamma (D) | Project Delta (E) | Assigned Projects (F) |
|---|---|---|---|---|---|
| John Doe | X | X | Project Alpha, Project Gamma | ||
| Jane Smith | X | X | X | Project Beta, Project Gamma, Project Delta | |
| Bob Johnson | (Blank) |
Our objective is to write a formula in column F that automatically looks across columns B through E, identifies which cells are not blank, and concatenates the corresponding headers from Row 1, separated by commas.
If you are using Microsoft 365 or Excel 2021, you have access to dynamic arrays. This makes the task incredibly simple by combining the TEXTJOIN and FILTER functions.
=TEXTJOIN(", ", TRUE, FILTER($B$1:$E$1, B2:E2 <
>
""))
FILTER($B$1:$E$1, B2:E2 <
>
""): This is the engine of the formula. The FILTER function looks at the header row ($B$1:$E$1) and returns only the headers where the corresponding cell in the current row (B2:E2) is not equal to empty (<
>
""). Note that we lock the header row with absolute references ($) so it doesn't shift when we copy the formula down.TEXTJOIN(", ", TRUE, ...): This function takes the array of headers returned by the FILTER function and glues them together.
", ") defines the delimiter (a comma and a space).TRUE) tells Excel to ignore any empty values, ensuring you don't get double commas if some columns are empty.Pros: Extremely clean, handles an infinite number of columns effortlessly, and adapts dynamically if columns are added or removed.
If you have Excel 2019, you have the TEXTJOIN function, but you do not have the FILTER function. In this case, you can use a logical IF statement inside TEXTJOIN as an array formula.
=TEXTJOIN(", ", TRUE, IF(B2:E2 <
>
"", $B$1:$E$1, ""))
Note: If you are in Excel 2019 or older, you must press Ctrl + Shift + Enter instead of just Enter to commit this as an array formula. When done correctly, Excel will wrap the formula in curly braces { }.
IF(B2:E2 <
>
"", $B$1:$E$1, "") checks each cell in the row. If the cell is not blank, it returns the header from the corresponding column. If it is blank, it returns an empty string ("").{"Project Alpha", "", "Project Gamma", ""}.TEXTJOIN then takes this array, ignores the empty strings (thanks to the TRUE argument), and joins the remaining headers with a comma and a space.If you are working with an older version of Excel that lacks the TEXTJOIN function, you cannot easily loop through arrays. Instead, you have to manually evaluate each column using string concatenation (&
) and conditional IF statements.
=SUBSTITUTE(TRIM(IF(B2<
>
"", $B$1&
" ","") &
IF(C2<
>
"", $C$1&
" ","") &
IF(D2<
>
"", $D$1&
" ","") &
IF(E2<
>
"", $E$1&
" ","")), " ", ", ")
Because we cannot use a; we have to build the; manually:
IF(B2<>"", $B$1&" ","") checks a single cell. If it's not blank, it appends the header name followed by a single space.& operator. For John Doe, this produces "Project Alpha Project Gamma ".TRIM function removes any extra spaces, including trailing or leading spaces, resulting in "Project Alpha Project Gamma".SUBSTITUTE replaces the spaces between words with a comma and space (", ").Warning: This legacy method works best if your headers are single words. If your headers contain spaces (like "Project Alpha"), TRIM and SUBSTITUTE will break the internal spaces of the header. For multi-word headers in older Excel versions, you must construct a tedious chain of nested substitutions or use a custom VBA function.
Sometimes, a cell might not be "blank," but it contains a value you want to ignore, such as "No", "N/A", or "0". You can easily modify the Modern Excel formula (Method 1) to target specific values.
For example, if you want to concatenate headers only when cells contain the word "Yes":
=TEXTJOIN(", ", TRUE, FILTER($B$1:$E$1, B2:E2 = "Yes"))
If you want to concatenate headers where cells contain a number greater than 0:
=TEXTJOIN(", ", TRUE, FILTER($B$1:$E$1, (ISNUMBER(B2:E2)) * (B2:E2 > 0)))
Always choose your formula based on your Excel version to ensure compatibility across your team:
TEXTJOIN.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.