Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

New Excel Functions: Text Cleaning Simplified

· 5 min read · Home Tech

In this article
  1. Background: The Old Way of Text Cleaning
  2. How the New Functions Work
  3. How to Choose the Right Function
  4. Common Problems and Solutions
  5. Comparisons: Old vs. New
  6. Costs and Availability
  7. Safety and Data Integrity
  8. Alternatives and Future Directions
  9. Frequently Asked Questions

Yes, the new Excel functions—TEXTSPLIT, TEXTBEFORE, TEXTAFTER, and the expanded VSTACK and HSTACK—have largely ended the era of complicated text cleaning formulas. These functions, available in Microsoft 365, replace many of the nested LEFT, RIGHT, MID, FIND, and SUBSTITUTE formulas that were once necessary for splitting, extracting, and rearranging text.

Background: The Old Way of Text Cleaning

Before these functions, cleaning text in Excel often meant building complex formulas. To split a full name into first and last, you might have used:

=LEFT(A1, FIND(" ", A1) - 1)

To extract the last word, you needed something like:

=RIGHT(A1, LEN(A1) - FIND("*", SUBSTITUTE(A1, " ", "*", LEN(A1) - LEN(SUBSTITUTE(A1, " ", "")))))

These formulas were not only hard to write but also difficult to read and maintain. They often broke when the data didn't match the expected pattern, and they required careful attention to every comma and parenthesis.

How the New Functions Work

The new text functions are designed to be intuitive and direct:

  • TEXTSPLIT splits text into rows or columns based on a delimiter. For example, =TEXTSPLIT(A1, ",") splits a comma-separated list into separate cells.
  • TEXTBEFORE returns the text before a given delimiter. =TEXTBEFORE(A1, " ") gives the first word.
  • TEXTAFTER returns the text after a delimiter. =TEXTAFTER(A1, " ") gives everything after the first space.
  • VSTACK and HSTACK combine arrays vertically or horizontally, making it easy to reassemble cleaned data.

These functions are part of Excel's dynamic array engine, which means they can spill results into multiple cells automatically. This is a fundamental shift from the old formula paradigm where each formula produced a single value.

How to Choose the Right Function

Choosing the right function depends on what you need:

  • If you need to split text into multiple parts, use TEXTSPLIT.
  • If you need only the part before a delimiter, use TEXTBEFORE.
  • If you need only the part after a delimiter, use TEXTAFTER.
  • If you need to combine multiple ranges or arrays, use VSTACK or HSTACK.

For example, to extract the domain from an email address, you can use =TEXTAFTER(A1, "@"). To get the username, use =TEXTBEFORE(A1, "@"). To split a full address into parts separated by commas, use =TEXTSPLIT(A1, ",").

Common Problems and Solutions

While these functions are powerful, they have a few quirks:

  • Missing delimiters: If the delimiter is not found, TEXTBEFORE returns a #N/A error. You can handle this with the IFERROR function or by using the optional if_not_found argument.
  • Multiple delimiters: TEXTSPLIT can handle multiple delimiters if you provide an array, like =TEXTSPLIT(A1, {",",";"}).
  • Case sensitivity: By default, these functions are case-insensitive. If you need case-sensitive matching, use the match_mode argument (0 for case-sensitive, 1 for case-insensitive).

Another common issue is that these functions are only available in Microsoft 365, not in older versions of Excel. If you're using Excel 2019 or earlier, you'll still need the old formulas.

Comparisons: Old vs. New

Let's compare the old and new approaches for a common task: extracting the first name from a full name.

Old formula: =LEFT(A1, FIND(" ", A1) - 1)

New formula: =TEXTBEFORE(A1, " ")

The new formula is shorter, clearer, and doesn't require knowing the position of the space. For extracting the last name, the old formula was a nightmare; the new one is simply =TEXTAFTER(A1, " ").

Another example: splitting a comma-separated list into columns. Old method: use Text to Columns wizard or a series of MID and FIND formulas. New method: =TEXTSPLIT(A1, ",") spills the results into adjacent cells automatically.

Costs and Availability

These functions are available to Microsoft 365 subscribers at no additional cost. They are part of the regular updates to Excel. However, if you're using a standalone version of Excel (like Excel 2021), you may have some of these functions, but not all. For example, TEXTSPLIT and TEXTBEFORE are available in Excel 2021, but VSTACK and HSTACK were added later and are only in Microsoft 365.

If you're on an older version, you might consider upgrading to Microsoft 365 to take advantage of these functions and other dynamic array features.

Safety and Data Integrity

When using these functions, it's important to consider data integrity:

  • Always test on a copy of your data first, especially if you're using formulas that overwrite original data.
  • Be aware that TEXTSPLIT can create more cells than you expect, which might overwrite existing data if not placed carefully.
  • Use the if_not_found argument to avoid errors when delimiters are missing.

These functions are not destructive by themselves, but careless use can lead to data loss if you're not careful about where results are placed.

Alternatives and Future Directions

While the new functions are excellent, there are alternatives:

  • Power Query: For complex text cleaning tasks, Power Query provides a visual interface and is often better for large datasets.
  • Flash Fill: For simple, one-off tasks, Flash Fill can automatically detect patterns and fill in data without formulas.
  • Regular expressions (Regex): In Excel, you can use VBA or Power Query to apply regex for advanced pattern matching, which is more powerful but requires more setup.

The new functions are a significant step forward, but they're not the end of text cleaning. For truly complex patterns, regex or Power Query may still be necessary.

Frequently Asked Questions

Are TEXTSPLIT and TEXTBEFORE available in Excel 2019?

No, these functions are only available in Microsoft 365 and Excel 2021 (partially). Excel 2019 does not include them, so you would need to use older formulas or upgrade.

Can I use TEXTSPLIT to split text into rows instead of columns?

Yes, TEXTSPLIT has a row_delimiter argument. By default, it splits into columns, but you can specify a row delimiter to split into rows. For example, =TEXTSPLIT(A1, ",", ";") would split by commas into columns and by semicolons into rows.

What happens if the delimiter is not found in TEXTBEFORE?

By default, it returns a #N/A error. However, you can use the third argument if_not_found to specify a value to return instead, like =TEXTBEFORE(A1, ",", 1, 1, "Not Found").

Can I use these functions with arrays?

Yes, these functions are designed to work with arrays. For example, you can use TEXTSPLIT on a range of cells and it will spill results for each cell, creating a dynamic array.

Do these functions work with Unicode and special characters?

Yes, they work with Unicode text, including emojis and accented characters. The delimiters can be any character or string, including special characters.

Is there a way to split text by multiple delimiters at once?

Yes, TEXTSPLIT accepts an array of delimiters. For example, =TEXTSPLIT(A1, {" ", ","}) splits by either a space or a comma.