Function Problems

How to Extract a Line Beginning with a Specific Word from an Excel Cell

Jason MillerJason Miller Nov 10, 2026 869 views

Question details

The user needs to clean Excel cells containing multiple lines of text by extracting only the specific line that begins with a certain target word.

How to Extract a Specific Line of Text from an Excel Cell
Product
Excel
Device & OS
not provided
Scenario
Cleaning messy data where hundreds of rows contain unwanted text around one required line, necessitating a formula to isolate the target string.
Observed behavior
The cell contains multiple lines separated by line breaks, and the user needs to return exclusively the line starting with a specified word.
Before you start

Identify the exact target word you are looking for and count its number of characters, as this will be required for the text extraction formula.

Solution 1Recommended

Use LET, TEXTSPLIT, and XLOOKUP in Microsoft 365

This modern formula quickly separates lines within a cell and returns the line that begins with your specific target word.

This approach leverages newer dynamic array formulas available in Microsoft 365. TEXTSPLIT breaks the multi-line cell into an array based on line breaks, while LEFT and XLOOKUP pinpoint the exact matching text.

1
Select the destination cell

Click on an empty cell in the row where you want the extracted line of text to appear.

2
Enter the dynamic extraction formula

Type the formula =LET(lines,TRIM(TEXTSPLIT(A1,,CHAR(10))),XLOOKUP(TRUE,LEFT(lines,4)="mesh",lines,"")) into the formula bar. Replace 'A1' with your source cell, 'mesh' with your specific word, and '4' with the character length of your specific word.

3
Apply the formula to your dataset

Press Enter to extract the text. Click the cell with your newly extracted line, then drag the fill handle from the bottom-right corner downward to apply this logic to the remaining rows.

Use LET, TEXTSPLIT, and XLOOKUP in Microsoft 365
Version Compatibility: This exact formula requires Microsoft 365, as the TEXTSPLIT and LET functions are not available in older standalone versions of Excel (like 2016 or 2019).
Advanced Data Processing

Extract Multi-line Cell Data Effortlessly with WPS Spreadsheet

WPS Spreadsheet provides powerful data processing tools, including advanced text formulas and robust text-to-columns functionality, helping you clean and organize messy data in seconds without complex setups.

  1. 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your workbook containing the multi-line cells that need cleaning.
  2. 2. Input the text extraction formula: Select a blank cell adjacent to your data and input your text manipulation formulas, or utilize the 'Text to Columns' tool located under the Data tab to split text by delimiters.
  3. 3. Process the entire column instantly: Double-click the fill handle in the bottom-right corner of your selected cell to instantly extract the target text lines for the rest of your dataset.
Fully compatible with Microsoft Excel formulas and .xlsx file formats.Fast and lightweight, ensuring smooth operation even with hundreds of thousands of rows.Free built-in features for efficient data cleaning, text extraction, and formatting.
microsoft office alternative - wps office

Frequently Asked Questions

What does CHAR(10) do in the text extraction formula?

CHAR(10) represents a line break (or line feed) character in Excel. In the formula, it tells the TEXTSPLIT function exactly where the cell's internal lines are separated so it can break the text block into individual segments.

Why am I getting a #NAME? error when using TEXTSPLIT?

The #NAME? error typically occurs if you are using a version of Excel that does not support the TEXTSPLIT or LET functions (such as Excel 2016 or 2019). You will need to use a helper-column approach, Power Query, or upgrade your software.

How can I extract a line containing a specific word, rather than just beginning with it?

Instead of using the LEFT function, you can use the SEARCH function combined with ISNUMBER. Modify the XLOOKUP criteria to look for a line where SEARCH returns a number, which means the word exists anywhere within that specific line.