Excel Formula: Extract first line of cell
In sometimes, there are several lines of contents in one Excel cell, if you just want to extract first line of contents into another cell, you can use a formula combined with LEFT function and SEARCH function.
|LEFT(txt, SEARCH(CHAR(10), txt)-1)|
|Txt: the cell contents you want to extract first line from.|
If there is blank or no char(10)(line break) in the text, it returns error value #VALUE!.
How this formula work
To extract first line from cell C3, please use below formula:
=LEFT(C3, SEARCH(CHAR(10), C3)-1)
Press Enter key.
CHAR(10): the line break.
SEARCH function finds the starting position of a character or text string in a given text. Here the formula SEARCH(CHAR(10), C3) finds the starting position of CHAR, returns 8.
LEFT function extracts text from left side of a text based on the given position. The formula =LEFT(C3, SEARCH(CHAR(10), C3)-1) can be seen as =LEFT(C3, 8-1), extracts 7 characters from left side of cell C3, returns “Combine”.
- Extract last line of cell
- Trim Text To N Words
Here introduces the formula to extract n words from left side of a text string.
- Split sentence into words
This tutorial provides formulas to separate words of sentence into separated columns.
- Split dollars and cents
To split dollars and cents into two columns with formulas in Excel.
- LEFT function
Extract text from left side.
- SEARCH function
Find a string within another string, and returns the starting position of the string inside another one.
- IF function
Test for conditions.
- MID function
Extract part of text from a cell value based on the location and length.