Use TEXTJOIN function to combine text values with optional delimiter. It is better than CONCATENATE because you can pass a range instead of individual cells and you can ignore empty cells too. Here is a sample use of TEXTJOIN Excel function.

TEXTJOIN Syntax & examples
To combine values in A1:A5 with comma separator, use =TEXTJOIN(",",,A1:A5) To ignore any blank values while concatenating, use =TEXTJOIN(",",TRUE, A1:A5)
TEXTJOIN Syntax: TEXTJOIN(delimiter, ignore empty values, range or list of values)
Why TEXTJOIN? Why not CONCATENATE or & operator?
- TEXTJOIN is easy
To combine values in A1:A5 with CONCATENATE, we have to write =CONCATENATE(A1, A2, A3, A4, A5) or A1&A2&A3&A4&A5
With TEXTJOIN, you can simply say =TEXTJOIN(,,A1:A5)
- Add delimiters
You can comma separate or add other delimiters when combining text with TEXTJOIN. While you can do the same with CONCATENATE, it becomes doubly annoying.
=TEXTJOIN(“, “,,A1:A5) gives you a comma separated text of values in A1:A5
3 Advanced TEXTJOIN uses
Here are three advanced examples of TEXTJOIN.
1. Combine values that meet a criteria
Let’s say you want to combine all player names for kickers team as shown aside. You can use TEXTJOIN with IF formula to do this.
=TEXTJOIN(“, “,TRUE,IF($C$36:$C$63=”kickers”,$B$36:$B$63,””))
The inner IF function returns an array of team members or blank depending on whether they are in kickers or not.
TEXTJOIN then ignores all blank values and returns comma seperated text.
Same formula with FILTER()
You can also use the newly introduced dynamic array function FILTER to do this job.
=TEXTJOIN(“, “,,FILTER(B36:B63,C36:C63=”kickers”))
Learn more about Excel Dynamic Array functions.
2. Reverse a text

You can use MID function to split a text value in to an array of characters and then reverse them with TEXTJOIN.
For example, below formula reverses “Chandoo”
=TEXTJOIN(,,MID(“Chandoo”,21-ROW($A$1:$A$20),1))
It works up to 20 letters.
How does it work?
MID(“Chandoo”,21-ROW($A$1:$A$20),1) portion returns an array of 20 items {“”;””;””;””;””;””;””;””;””;””;””;””;””;”o”;”o”;”d”;”n”;”a”;”h”;”C”}
This is then combined by TEXTJOIN to return 00dnahC
3. Substitution cipher with TEXTJOIN
Want to communicate in a secret code with your colleague? You can use substitution cipher to map each letter with another letter of alphabet.
We can use either XLOOKUP or VLOOKUP with TEXTJOIN to encrypt text values like this.
Imagine you have a mapping table as shown aside.
To convert a message in cell H92, use this formula
=TEXTJOIN(,,XLOOKUP(MID(H92,ROW($A$1:$A$20),1),subs[Normal], subs[Code],””))
How does it work?
Using the MID() function, we split the text in H92 into an array of 20 values, one per character.
We then pass these letters to XLOOKUP to find matching [Code] from the subs table.
All these values are finally combined by TEXTJOIN to generated our coded message.
What the function - TEXTJOIN in Excel video
I recently started a series of videos on my Youtube channel to demystify Excel functions. This series is named What the function. Watch below WTF tutorial on TEXTJOIN to learn how to use it.
Download TEXTJOIN Example Workbook
Click here to download the TEXTJOIN example file. Use the sample data and formulas to understand TEXTJOIN function better. Play with the data to create something cool on your own and post your TEXTJOIN ideas in the comments.
TEXTJOIN in use - Excel Risk Map
If you want to get some inspiration on how TEXTJOIN can be a force of good, see this Excel risk map. It uses TEXTJOIN to show risks in a matrix format.














17 Responses to “Custom Number Formats – Colors”
You are right, Chandoo. I was playing with the colour numbers last week and some of them don't appear different from each other. Others are totally different from yours.
@Duncan
Each version of Excel, post 2003, renders colors slightly differently
Different language versions may also have different default color palettes
Hello in french
excel 2010
colo1 = couleur1 = black
[couleur1]; [couleur2]; etc..
@Hui, thank you very much again for this great post.
However - under Excel 2007, Hungarian version your solution does not work with color names. I've tried both English and Hungarian names, but drops an error message "not valid formats"
Do you have any idea how to solve this issue?
thanks in advance
@Andras
Without a Hungarian version of Excel 2003 I don't think I can assist
Have you tried using the colour numbers? I couldn't get the names to work (despite using an english version of excel). but it did work with the numbers though. I left out the "u" and was easily able to produce burgundy using [color9]
Here a possible solution: find an English version of Excel, write there the formats using English names, then open the file in the Hungarian version and see the translation.
In Excel 2007 I can't get the colour names to work e.g Sea Green but the numbers do e.g color3 - colour3 does not work so I must bow to the country that has stolen my language (ha ha!)
Hey chandoo, nice Tip!
Wouldn't be easier just apply some conditional formatting for negative numbers and another for positive numbers? Or there's some cases that you can't do that?
Unfortunately the TEXT function doesn't color the cell as number formatting does.
Hi Hui,
Great post Sir, love the new way of formatting with color numbers.
I am using 2007, and it leads me to the last color number 56.
Thanks Hui.
[…] explains how to set up custom number formats with a wide array of […]
Thanks Hui - works a treat!
Thank you, very helpful.
Trying to figure out if it is possible to apply color only to a part of the cell?
E.g. I have a value formatted as Accounting with a currency symbol.
Those I find somewhat distracting though necessary. If I could make them less obtrusive by coloring them gray while the number would stay black, that would be great. Tried tinkering with the format string, but didn't get the desired result. Single color for complete cell value works, but coloring just part of it could not be achieved. Maybe somebody managed that?
Exactly what I was looking for - thank you!
colour in the Australian doesn't work - we have to go American and no problem.
I always thought is was 56 colours notice you have 57. Cool.
thanks
Analir Pisani
Customised Microsoft Office Training Specialist
Sydney - Australia
http://www.azsolutions.com.au
Thank You!