Quick, clean, and to the point

Text split to array

Excel formula: Text split to array
Generic formula 

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:


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:


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 element, enclosed with a parent element. We start with the SUBSTITUTE function here:


The result from SUBSTITUTE is a text string like this:


To ensure well-formed XML tags and to wrap all elements in a parent element, we prepend and append more XML tags like this:


This yields a text string like this (line breaks added for readability)


This text is delivered directly to the FILTERXML function as the xml argument, with an Xpath expression of "//y":


Xpath is a parsing language and "//y" selects all elements. The result from FILTERXML is a vertical array like this:


Because we want a horizontal array in this instance, we wrap the TRANSPOSE function around FILTERXML:


The result is a horizontal array like this:


which spills into the range D5:H5 in Excel 365.

Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 200+ Excel Shortcuts

Get over 200 Excel shortcuts for Windows and Mac in one handy PDF.