Use TEXTJOIN function to combine text values with optional delimiter - KING OF EXCEL

KING OF EXCEL

KINGEXCEL.INFO ( KING OF EXCEL ) Welcome KINGEXCEL.INFO - Nothing Is Unable ... About Excel Tricks, Learning VBA Programming, Dedicated Software, Accounting, Living Skills ...

Saturday, July 25, 2020

Use TEXTJOIN function to combine text values with optional delimiter

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 excel function demo

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.

textjoin-combine only matching values1. 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”))

2. Reverse a text

reverse text with textjoin
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

substitution cipher with textjoinWant 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

Download TEXTJOIN Example Workbook

Click here to download the TEXTJOIN example fileUse 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

Excel Risk Map TemplateIf 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.
#evba #etipfree #eama #kingexcel
📤How to Download ebooks: https://www.evba.info/2020/02/instructions-for-downloading-documents.html?m=1

No comments:

Post a Comment