You are on page 1of 3

EXCEL

specify that empty values


should be ignored. This will pre-
vent two consecutive delimiters
from appearing. Say that you re-
moved Charlie from cell A4 in
Figure 1. By specifying TRUE for
the Ignore_Empty argument,
you will get Andy, Betty, Dale in-

USING TEXTJOIN WITH AN ARRAY


stead of Andy, Betty, , Dale.
l The text arguments (Text1,
Text2, etc.) can specify a range.
It can be one column, like A1:A26,
or multiple columns, like A1:Z26.
Six new calculations have been added since last year It can even be a 3-D reference,
for Office 365 subscribers. One of those, the TEXTJOIN such as ‘Jan 2018:Dec 2018’!A1:Z26.

function, is proving to be more flexible and more SUPPORT FOR ARRAY FORMULAS
powerful than it originally appeared. When Array formulas are a powerful class of
formulas in Excel. These formulas can
TEXTJOIN was introduced in 2017, it seemed like Microsoft perform a calculation over several
was trying to improve deficiencies in the CONCATENATE cells in a range and then return the
results to another function. While
function. But there’s more to it. array formulas are powerful, they
don’t work with most Excel functions.
They certainly never worked with
BY BILL JELEN CONCATENATE.
While Excel Help doesn’t reveal it,
the TEXTJOIN function does support
an array as the third argument. This
In the past, if you wanted to concate- allows you to do some interesting cal-
nate a list of names in column A, you culations inside of TEXTJOIN. Say that
couldn’t use a simple formula such as you wanted to retrieve a list of people
=CONCATENATE(A1:A26). Instead, you who RSVP’d “Yes” to an event.
had to specify each cell individually: In Figure 2, column A contains the
=CONCATENATE(A1,A2,A3,A4,A5,…A26). names. Column B contains “Yes” or
Unless the values stored in column A “No” for RSVP. You want to find all of
happened to have trailing spaces, you the people who have a RSVP value of
would end up with a hard-to-read re- Yes. The array portion of the formula
sult like AndyBettyCharlieDaleEddy. is IF(B2:B26=“Yes”,A2:A26,“”). In English,
See more figures TEXTJOIN offers some improve- this formula says, “If column B says
in the online ments over CONCATENATE. The Yes, then return the name in column
version at: syntax of TEXTJOIN is =TEXTJOIN A; otherwise return an empty text.”
(Delimiter, Ignore_Empty, Text1, The consecutive quotation marks (“”)
[Text2],…). Here’s how it works: indicate an empty value.
Using this array formula as the
l The first argument lets you third argument to TEXTJOIN sends
specify a delimiter to appear be- Andy, Betty, “”, Dale, Eddy, “”, Gloria to the
tween each value. For example, TEXTJOIN function. If you specify
including “, ” would make sure TRUE for the Ignore_Empty argu-
that the names appear with a ment, Excel will return Andy, Betty,
comma and space between Dale, Eddy, Gloria.
them: Andy, Betty, Charlie, Dale, Like most array formulas, you
Eddy. (See Figure 1.) have to use a special shortcut key.
l In the second argument, you can Type =TEXTJOIN(“, ”,TRUE,IF(B2:B26=“Yes”,

58 / STRATEGIC FINANCE / April 2018


A2:A26,“”)), but don’t press Enter. Instead, hold
down Ctrl+Shift, then press Enter. Release
Ctrl+Shift. This keystroke combination, called
Ctrl+Shift+Enter, is required any time you enter
or edit an array formula. If you do the keystroke
correctly, you’ll see curly braces around the for-
mula in the formula bar.

RETURNING ALL MATCHES FROM A VLOOKUP


The VLOOKUP function returns only the first
match found in the specified lookup table. I often Figure 1
have people ask me if they can return all match-
ing values.
If you’re looking up numbers, you can replace
the VLOOKUP with SUMIF or SUMIFS. Say that
you have product in A, customer in B, revenue in
C. Using =VLOOKUP(“Orange”,A2:C15,2,False) will re-
turn the first customer who purchased an orange.
Using =VLOOKUP(“Orange”,A2:C15,3,False) will return
the price of the first order.
Ever since Excel 97, you could sum all of the
revenue from orders for oranges using =SUMIF
(A2:A15,E2,C2:C15). But there wasn’t an easy way to
return a list of all of the customers who had pur-
chased oranges. Figure 2
By using =TEXTJOIN(“, “,TRUE,IF(A2:A15=E2,B2:
B15,”“)) followed by Ctrl+Shift+Enter, you can re-
turn a list of all of the customers who purchased
an orange.

SUPPORT FOR 3-D RANGES


I was having a casual conversation with one of
the Excel team project managers who wrote the
specification for the TEXTJOIN function. I was
thrilled when he mentioned that TEXTJOIN
would support arrays. I was unsure when I
would ever have a use for 3-D references, but
you can specify that you want to concatenate all
of the cells in all of the sheets. For example: =TEXT
JOIN(“, “,True,January:December!A1:Z26) will return
any value found in cells A1:Z26 of every work-
sheet between (and including) January and
December.
The TEXTJOIN function is currently only in
the subscription versions of Office 365. If you
own a perpetual license of Excel, you’ll have to Along with TEXTJOIN, Office 365
wait until Office 2019 ships later this year for the subscribers can also use the
new functionality. SF
new IFS, MAXIFS, MINIFS, SWITCH,
and CONCAT functions.
Bill Jelen is the host of MrExcel.com. Send questions for
future articles to IMA@MrExcel.com.

April 2018 / STRATEGIC FINANCE / 59


Copyright of Strategic Finance is the property of Institute of Management Accountants and its
content may not be copied or emailed to multiple sites or posted to a listserv without the
copyright holder's express written permission. However, users may print, download, or email
articles for individual use.

You might also like