# How to use the TEXTSPLIT function

The TEXTSPLIT function lets you split a string into an array across columns and rows based on delimiting characters.

Formula in cell E3:

The TEXTSPLIT function is available to Excel 365 users.

#### Table of Contents

- TEXTSPLIT Function Syntax
- TEXTSPLIT Function Arguments
- TEXTSPLIT Function example
- Split string using multiple delimiting characters
- How to create a string containing column and row delimiting characters
- How to split date value
- Rearrange values to the left if the cell is empty as far as possible
- Rearrange values to fill empty cells
- How to create name initials
- Get Excel *.xlsx file

## 1. TEXTSPLIT Function Syntax

TEXTSPLIT(*Input_Text*, *col_delimiter*, [*row_delimiter*], [*Ignore_Empty*])

## 2. TEXTSPLIT Function Arguments

Input_Text |
Required. The original string. |

col_delimiter |
Required. The delimiter characters to use, splits the string into columns. |

Â [row_delimiter] |
Optional. The delimiter characters the TEXTSPLIT function uses to split the string into rows. |

[Ignore_Empty] |
Optional. Default value is FALSE. TRUE creates an empty value if the space between delimiting characters is empty. |

[pad_with] |
Optional. A string to use, the string is concatenated to each value in the array. The default value is nothing. |

## 3. TEXTSPLIT Function example

The formula in cell B6 splits the text string in cell B3 based on a space character and a dot. This creates an array with a word in each cell. A new sentence is located on a new row.

The array may now contain array values that contain #N/A error values meaning there are no values in that particular location.

Formula in cell E4:

### 3.0.1 Explaining formula

#### Step 1 - TEXTSPLIT function

TEXTSPLIT(*Input_Text*, *col_delimiter*, [*row_delimiter*], [*Ignore_Empty*], [*pad_with*])

#### Step 2 - Populate arguments

*input_text - B3
col_delimiter - " "
[row_delimiter] - "."
*

#### Step 3 - Evaluate function

TEXTSPLIT(B3," ",".",TRUE)

returns {"Dui", "viverra", "tempor", #N/A,... , #N/A}

## 3.1 TEXTSPLIT function - remove #N/A errors

You can use the IFNA function to remove possible #N/A errors.

Formula in cell E4:

### 3.1.1 Explaining formula

#### Step 1 - Create array

TEXTSPLIT(B3," ",".",TRUE)

returns

{"Dui", "viverra", "tempor", #N/A, ... , #N/A}

#### Step 2 - Remove #N/A error values

The IFNA function lets you replace #N/A errors with a given string.

IFNA(*value*,Â *value_if_na*)

IFNA(TEXTSPLIT(B3," ",".",TRUE),"")

returns {"Dui","viverra",... ,""}

## 3.2 TEXTSPLIT function - pad each value with a given string

You also have the option to pad each value in the array with any string. I will be padding in this example a single space character.

Formula in cell E4:

### 3.0.1 Explaining formula

#### Step 1 - TEXTSPLIT function

*input_text - B3
col_delimiter - " "
[row_delimiter] - "."
[Ignore_Empty] - Default value is FALSE. TRUE creates an empty value if the space between delimiting characters is empty.
[pad_with] - " "*

TEXTSPLIT(*Input_Text*, *col_delimiter*, [*row_delimiter*], [*Ignore_Empty*], [*pad_with*])

TEXTSPLIT(B3," ",".",TRUE," ")

becomes

TEXTSPLIT("Dui viverra tempor. Phasellus porta orci laoreet condimentum vulputate.

Mauris dignissim odio sit amet ullamcorper lobortis.

Vivamus pulvinar, enim vitae iaculis vehicula, purus sapien interdum tellus, viverra congue diam tortor sed quam.

Pellentesque et pulvinar dolor.

Suspendisse euismod."," ",".",TRUE," ")

and returns

{"Dui","viverra",... ," "}

#### Step 2 - Remove space characters

The TRIM function removes leading and trailing space characters.

TRIM(*text*)

TRIM(TEXTSPLIT(B3," ",".",TRUE," "))

returns {"Dui","viverra",... ,""}

## 4. Split string using multiple delimiting characters

The string in cell B3 contains both dots and semicolons as an end of a sentence. You can use multiple delimiting characters to create a new column or row.

Formula in cell B6:

=TEXTSPLIT(B3," ",{".",";"},TRUE)

### 4.1 Explaining formula

*input_text - B3
col_delimiter - " "
[row_delimiter] - {".",";"}
[Ignore_Empty] - Default value is FALSE. TRUE creates an empty value if the space between delimiting characters is empty.
*

TEXTSPLIT(*Input_Text*, *col_delimiter*, [*row_delimiter*], [*Ignore_Empty*], [*pad_with*])

TEXTSPLIT(B3," ",{".",";"},TRUE)

returns {"Dui", "viverra", ... , #N/A}

## 5. How to create a string containing column and row delimiting characters

This section describes how to create a string using delimiting characters, based on your regional settings, from a cell range.

The TEXTJOIN function concatenates values from a cell range and is the opposite to the TEXTSPLIT function, however, it can't use delimiting characters for bor columns and rows.

- Double press with the left mouse button on cell B10, a prompt appears.
- Type = (equal sign)
- Select the cell range, in this example cell range B3:J8.
- Press F9 to convert the cell reference to constants.
- Remove the equal sign and the curly brackets { }.
- Press Enter.

My regional settings return a comma for a column delimiting character and a semicolon for a row delimiting character.

## 6. How to split dates

The formula in cell D3 splits the date specified in cell B3 into an array containing month, day, and year based on the slash character.

You can of course use whatever delimiting character you want, make sure you change the TEXT and TEXTSPLIT function arguments accordingly.

Dynamic array formula in cell D3:

### Explaining formula

#### Step 1 - Create a text string

Excel dates are actually just numbers, to split a date we need to create a text value.

The TEXT function creates text values based on a formatting pattern.

TEXT(*value*,Â *format_text*)

TEXT(B3, "mm/dd/yyyy")

becomes

TEXT(44649, "mm/dd/yyyy")

and returns "03/29/2022".

#### Step 2 - Split text string

TEXTSPLIT(TEXT(B3, "mm/dd/yyyy"), "/")

becomes

TEXTSPLIT("03/29/2022", "/")

and returns

{"03", "29", "2022"}.

## 7. Move values to the left if cell is empty as far as possible

The image above shows a cell range containing values and random empty cells, here is how to move values to the left in the cell range as far as possible using a formula.

The TEXTJOIN function adds only one delimiting character to the string, however, there may be multiple instances of the same character. You can not specify a row delimiting character in the TEXTJOIN function.

I have added semicolons to column K to solve this problem, both delimiting characters let the TEXTSPLIT function split values to both columns and rows.

Formula in cell B16:

### Explaining formula

Make sure you add a row delimiting character to the right of the last value on each row, it doesn't have to be a semicolon. You can use whatever character you want.

You are allowed to specify the row delimiting character in the TEXTSPLIT function.

#### Step 1 - Join values in cell range B3:K13

The TEXTJOIN function allows you to combine text strings from multiple cell ranges and also use delimiting characters (optional).

TEXTJOIN(*delimiter*,Â *ignore_empty*,Â *text1*,Â *[text2]*, ...)

TEXTJOIN(",",,B3:K13)

#### Step 2 - Split string ignoring blank values

TEXTSPLIT(TEXTJOIN(",",,B3:K13),",",";",TRUE,"")

## 8. Move values to fill empty cells

This example demonstrates a formula that rearranges all values in order to remove blank cells.

Excel 365 dynamic array formula in cell B16:

### Explaining formula

#### Step 1 - Join cell values

The TEXTJOIN function allows you to combine text strings from multiple cell ranges and also use delimiting characters (optional).

TEXTJOIN(*delimiter*,Â *ignore_empty*,Â *text1*,Â *[text2]*, ...)

TEXTJOIN(",",,B3:K13)

#### Step 2 - Split values to an array

TEXTSPLIT(TEXTJOIN(",",,B3:K13),",",,TRUE,"")

#### Step 3 - Rearrange array to nine columns

The WRAPROWS function rearranges values from a 1D array to a 2D array.

WRAPROWS(*vector*,Â *wrap_count*, [*pad_with*])

WRAPROWS(TEXTSPLIT(TEXTJOIN(",",,B3:K13),",",,TRUE,""),9,"")

## 9. How to create name initials

The array formula in cell C3 extracts the first character from first, middle and last name. The formula works fine with more or less names, up to 1000 characters. You can easily edit the formula if you need more letters.

Excel 365 dynamic array formula in cell C3:

Array formula in cell C3:

To enter an array formula, type the formula in a cell then press and hold CTRL + SHIFT simultaneously, now press Enter once. Release all keys.

The formula bar now shows the formula with aÂ beginning and ending curly bracket telling you that you entered the formula successfully. Don't enter the curly brackets yourself.

### Explaining formula in cell C3

#### Step 1 - Split name into characters

The MID function returns characters from a text string based on a start number and the number of characters. The ROW function creates an array in this case that we need to split the text string into characters. The TRIM function removes leading and trailing spaces.

MID(" "&TRIM(B3), ROW($B$1:$B$1000), 1)

becomes

MID(" "&TRIM(B3), {1;2;3;4;5;6;7;8;9; ... ; 1000}, 1)

becomes

MID(" Atticus Esteban Griffith", {1;2;3;4;5;6;7;8;9; ... ; 1000}, 1)

and returns

{" ";"A";"t";"t";"i";"c";"u";"s";" "; "E";"s";"t";"e";"b"; "a";"n";" ";"G";"r"; "i";"f";"f";"i"; "t";"h";""; ... ;""}.

#### Step 2 - Check if a character is a space (blank)

The IF function replaces space characters with the next character.

IF(MID(" "&TRIM(B3), ROW($B$1:$B$1000), 1)=" ", " "&MID(TRIM(B3), ROW($B$1:$B$1000), 1), "")

returns {" A";""; ... ; ""}

#### Step 3 - Concatenate characters

The TEXTJOIN function concatenates characters in an array and in this case ignoring empty array values.

TRIM(TEXTJOIN("", TRUE, IF(MID(" "&TRIM(B3), ROW($B$1:$B$1000), 1)=" ", " "&MID(TRIM(B3), ROW($B$1:$B$1000), 1), "")))

becomes

TRIM(" A E G")

The TRIM function removes leading and trailing spaces.

TRIM(" A E G") returns "A E G" in cell C3.

### Get excel *.xlsx file

### Useful links

TEXTSPLIT function - Microsoft

### 'TEXTSPLIT' function examples

This blog article describes how to split strings in a cell with space as a delimiting character, like Text to […]

This article demonstrates two ways to calculate the number of times each word appears in a given range of cells. […]

Table of Contents How to use the CHOOSECOLS function How to use the CHOOSEROWS function How to use the DROP […]

### Functions in 'Text' category

The TEXTSPLIT function function is one of 30 functions in the 'Text' category.

### Excel function categories

### Excel categories

### 16 Responses to “How to use the TEXTSPLIT function”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

I have some shorter formulas for you...

Initials from first and last names

------------------------------------

=LEFT(TRIM(A2))&" "&MID(TRIM(A2),FIND(" ",TRIM(A2))+1,1)

Initials from first, middle and last names

-----------------------------------------------------------------

=TRIM(LEFT(TRIM(A2))&" "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99)))&" "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),199,99)))&" "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),298,99))))

Create middle name initials

---------------------------------------------------

=CHOOSE(LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ","")),TRIM(A2),SUBSTITUTE(TRIM(A2)&" "," "&TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99))&" "," "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99)))&". "),SUBSTITUTE(SUBSTITUTE(TRIM(A2)&" "," "&TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99))&" "," "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99)))&". ")," "&TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),199,99))&" "," "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),199,99)))&". "))

My "Initials from first and last names" formula is only 3 characters shorter (taking advantage of the LEFT functions default behavior); however my "Initials from first, middle and last names" formula is about half the size of yours and my "Create middle name initials" formula is a little more than 60% the size of yours.

Rick Rothstein (MVP - Excel),

Great, they worked perfectly!

Thanks for posting!

[...] How to create initials from a list of first, middle and last names [Get Digital help] [...]

Oscar, have I got a treat for you. Assuming that there will never be any cells with more than four names in it, here is an amazingly short formula (considering what has been posted earlier) that I have just come up with...

=LEFT(A2,FIND(" ",A2))&IF(LEN(A2)-LEN(SUBSTITUTE(A2," ",""))>1,LEFT(TRIM(A3))&LEFT(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),100,99)))&". ","")&IF(LEN(A2)-LEN(SUBSTITUTE(A2," ",""))=3,LEFT(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),199,99)))&". ","")&TRIM(LEFT(RIGHT(SUBSTITUTE(" "&A2," ",REPT(" ",99)),99),99))

Sorry, I forgot to mention... the formula is for creating middle name initials.

Okay, in addition to the much shorter formula for creating middle name initials that I just posted above, here is a shorter formula for the initials from first, middle, last names as well...

=TRIM(LEFT(A2)&" "&LEFT(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),100,99)))&" "&LEFT(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),199,99))))

Rick Rothstein (MVP - Excel),

Thank you for commenting!

I canÂ´t get your formulas working, check out the attached file. Sheet 2 and column C and D.

Initialsv2.xlsx

I suspect wordpress removing characters.

@Oscar,

It looks like I had copied the wrong formula for the "creating middle name initials"... there was an A3 reference that should have been an A2 reference and there was an extra TRIM function call concatenated onto the part displaying the first initial... I remember having fixed both of those before posting, so I must have copied the wrong formula when I created my comment here. Sorry. Fixing those made the formula into the final form I meant to post, but that did not take care of all the problems though, as I did not account for extra leading and trailing spaces around the names (which is why the "initials from first, middle, last names" formula failed as well). Here are the fixed formula which should now work for you (longer than originally intended because of the added TRIM function calls to take care of the leading and trailing spaces, but still noticeably shorter than my previous short formulas from last year)...

Creating middle name initials

-----------------------------------------------------------

=LEFT(TRIM(A2),FIND(" ",TRIM(A2)))&IF(LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))>1,LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99)))&". ","")&IF(LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))=3,LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),199,99)))&". ","")&TRIM(LEFT(RIGHT(SUBSTITUTE(" "&TRIM(A2)," ",REPT(" ",99)),99),99))

Initials from first, middle, last names

-----------------------------------------------------------

=TRIM(LEFT(TRIM(A2))&" "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99)))&" "&LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),199,99))))

By the way, I noticed you had array-entered the formulas in the workbook you linked to in your last message... the above formulas do not need to be array-entered, they will work fine when normally entered.

Silly me... I have two occurances in my "Creating middle name initials" formula where I TRIM cell A2 only to then follow do that by removing all the spaces in cell A2. Removing those two unnecessary TRIM function calls shortens the formula by 12 characters without affecting the formulas ultimate action. Here is that revised formula...

=LEFT(TRIM(A2),FIND(" ",TRIM(A2)))&IF(LEN(TRIM(A2))-LEN(SUBSTITUTE(A2," ",""))>1,LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),100,99)))&". ","")&IF(LEN(TRIM(A2))-LEN(SUBSTITUTE(A2," ",""))=3,LEFT(TRIM(MID(SUBSTITUTE(TRIM(A2)," ",REPT(" ",99)),199,99)))&". ","")&TRIM(LEFT(RIGHT(SUBSTITUTE(" "&TRIM(A2)," ",REPT(" ",99)),99),99))

Rick Rothstein (MVP - Excel),

I got your formulas working, thanks for posting!

[…] How to create initials from a list of first, middle and last names [Get Digital help] […]

[…] How to create initials from a list of first, middle and last names [Get Digital help] […]

[…] How to create initials from a list of first, middle and last names [Get Digital help] […]

[…] How to create initials from a list of first, middle and last names [Get Digital help] […]

please check parameter optional or required?

dang d. khanh,

Which argument?

An argument without brackets is required, an argument with brackets is optional.