If you need to split or extract text from a Microsoft Excel spreadsheet, there are a few different ways to go about it. The easiest way is to use the Text Box tool in the Home tab of the ribbon. This will open up a dialog box where you can type in the text that you want to split or extract. If you want to split text based on a specific character, you can use the Find and Replace feature in Excel. This will allow you to search for specific characters and then replace them with another string of text. You can also use the Split Text command in the Home tab of the ribbon if you just want to split text based on a certain delimiter, such as a comma or semicolon. ..
Microsoft Excel offers a set of functions for working with text. When you want to extract part of a text string or split a string into rows or columns, there are three particular functions that get the job done.
With TEXTBEFORE and TEXTAFTER, you can pull out text before or after a certain word or character. This makes these functions more flexible than the LEFT, RIGHT, and MID functions you might be using. For splitting a string into various cells, you can use TEXTSPLIT.
The TEXTBEFORE Function
The syntax for the function is TEXTBEFORE(text, delimiter, instance, match_mode, match_end, if_not_found). The first two arguments are required with text being either the actual text or a cell reference and delimiter being the point at which you want the text before.
Here are descriptions of the three optional arguments:
Instance: Use this argument if there is more than one occurrence of the delimiter in the string and you want a particular one. Match_mode: Enter a 0 for case sensitive or 1 for not case sensitive. The default is 0. Match_end: Enter 0 to not match the delimiter to the end of the text and 1 to match it. The default is 1. If_not_found: Use this argument If you prefer a result rather than an error for values not found.
Now that you know the arguments, let’s look at some example uses for TEXTBEFORE.
In this first example, we’ll extract all text before the word “from” in cell A2 using this formula:
Using this next formula, we’ll extract all text before the second instance of the word “text.”
For one more example, we’ll use the match_mode argument for a case-sensitive match.
RELATED: 13 Essential Excel Functions for Data Entry
The TEXTAFTER Function
TEXTAFTER is the exact opposite of TEXTBEFORE. The syntax for the function is TEXTAFTER(text, delimiter, instance, match_mode, match_end, if_not_found).
Like its counterpart, the first two arguments are required with text being either the actual text or a cell reference and delimiter being the point at which you want the text after.
The three optional arguments described above also work the same as the TEXTBEFORE function.
In this first example, we’ll extract all text after the word “from” in cell A2 using this formula:
Using this next formula, we’ll extract all text after the second instance of the word “text.”
And finally, we’ll use the match_mode argument for a case-sensitive match.
The TEXTSPLIT Function
With the TEXTSPLIT function you can split the text into cells in a row or column based on the delimiter, for example, a space or period.
RELATED: How to Split Data Into Multiple Columns in Excel
The syntax is TEXTSPLIT(text, column_delimiter, row_delimiter, ignore, match_mode, pad_with) where the first argument is required and can be actual text or a cell reference. By default, the formula splits the text into columns, but you can use rows instead with the row_delimiter argument.
Here are descriptions of the remaining arguments:
Ignore: Enter FALSE to create an empty cell when two delimiters are consecutive. The default is TRUE. Match_mode: Searches the delimiter for a match with the default as case sensitive. Pad_with: To pad the result, enter a value. Otherwise, the #N/A error displays.
In this example, we’ll split the text string in cell A2 across columns with a space as our column_delimiter in quotes. Here’s the formula:
Instead of splitting the string across columns, we’ll split it across rows using a space as our row_delimiter with this formula:
Notice in this formula, we leave the column_delimiter argument blank and only use the row_delimiter.
For this next example, we’ll split only after the semicolon into another column:
Next, we’ll split only after the semicolon into a row instead of a column:
The TEXTSPLIT function is a powerful one. If you’re looking for more complex examples of using the optional arguments, visit the Microsoft Support page for the TEXTSPLIT function.
The next time you want to extract text from a cell or split a long text string, keep these Excel functions in mind.
RELATED: 12 Basic Excel Functions Everybody Should Know