Text split to array

=FILTERXML("<x><y>"&SUBSTITUTE(A1,",","</y><y>")&"</y></x>","//y")
To split text with a delimiter and transform the result into an array, you can use the FILTERXML function with help from the SUBSTITUTE and TRANSPOSE functions. In the example shown, the formula in D5 is:
=TRANSPOSE(FILTERXML("<x><y>"&SUBSTITUTE(B5,",","</y><y>")&"</y></x>","//y"))
Note: FILTERXML is not available in Excel on the Mac, or in Excel Online.
Note: I learned this trick from Bill Jelen in a MrExcel video.
Excel does not have a function dedicated to splitting text to an array, similar to the PHP explode function, or Python split method. As a workaround, you can use the FILTERXML function, after first adding XML markup to the text.
In the example shown, we have several comma-delimited text strings like this:
"Jim,Brown,33,Seattle,WA"
The goal is to split the information into separate columns using the comma as a delimiter.
The first task is to add XML markup to this text, so that it can be parsed as XML with the FILTERXML function. We are going to arbitrarily make each field in the text a
SUBSTITUTE(B5,",","</y><y>")
The result from SUBSTITUTE is a text string like this:
"Jim</y><y>Brown</y><y>33</y><y>Seattle</y><y>WA"
To ensure well-formed XML tags and to wrap all
"<x><y>"&SUBSTITUTE(B5,",","</y><y>")&"</y></x>"
This yields a text string like this (line breaks added for readability)
"<x> <y>Jim</y> <y>Brown</y> <y>33</y> <y>Seattle</y> <y>WA</y> </x>"
This text is delivered directly to the FILTERXML function as the xml argument, with an Xpath expression of "//y":
FILTERXML("<x><y>Jim</y><y>Brown</y><y>33</y><y>Seattle</y><y>WA</y></x>","//y")
Xpath is a parsing language and "//y" selects all
{"Jim";"Brown";33;"Seattle";"WA"}
Because we want a horizontal array in this instance, we wrap the TRANSPOSE function around FILTERXML:
=TRANSPOSE({"Jim";"Brown";33;"Seattle";"WA"})
The result is a horizontal array like this:
{"Jim","Brown",33,"Seattle","WA"}
Download 100+ Important Excel Functions
Get over 100 Excel Functions you should know in one handy PDF.