How to Extract Text Before the First Comma in Excel
Question details
The user needs a formula to extract only the text located before the first comma in a cell, while retaining the original text if no comma is present.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Cleaning and extracting specific data points from a column that contains mixed comma-separated text values.
- Observed behavior
- A clean target column that displays the text prior to the comma, or the unmodified original string for cells lacking a comma.
Ensure your dataset is organized in a single column and create an empty adjacent column to output your newly extracted text.
Use the LEFT, SEARCH, and IFERROR Formula
This method dynamically locates the first comma, extracts everything to its left, and handles cells without commas gracefully.
By combining three powerful text functions, you can extract precisely what you need while avoiding errors on cells that don't match the comma-separated format.
Click on cell B2 (or the first cell in your blank destination column) where you want the extracted text to appear.
Type the formula: =IFERROR(LEFT(A2,SEARCH(",",A2)-1),A2) into the formula bar.
Press Enter to view the result, then click and drag the fill handle at the bottom-right corner of the cell downwards to apply the formula to the rest of the column.

Use the Text to Columns Feature
If you prefer a non-formula approach, you can physically split the text by the comma delimiter directly.
Extract and Manipulate Text Seamlessly Using WPS Spreadsheet
WPS Spreadsheet fully supports advanced text formulas like LEFT, SEARCH, and IFERROR, allowing you to clean, extract, and format your data quickly and intuitively.
- 1. Open Data: Launch WPS Spreadsheet and open the document containing your text data.
- 2. Select Target Cell: Click on the destination cell next to your existing text.
- 3. Input Formula: Type =IFERROR(LEFT(A2,SEARCH(",",A2)-1),A2) and press the Enter key.
- 4. Drag to Apply: Double-click or drag the small square at the bottom right of the cell to fill the rest of the column.

Frequently Asked Questions
How do I extract text after the first comma?
You can use the MID function to start extracting after the comma's position. Use this formula: =IFERROR(MID(A2,SEARCH(",",A2)+2,LEN(A2)),""). This skips the comma and the following space.
Why does my LEFT and SEARCH formula return a #VALUE! error?
The #VALUE! error occurs when the SEARCH function looks for a character (like a comma) that does not exist in the cell. Wrapping your formula in the IFERROR function prevents this by providing a fallback value, such as returning the original string.
Can I use this formula to extract text before a hyphen or space instead?
Yes. You simply need to replace the comma within the quotation marks in the SEARCH function with your desired character. For example, to search for a hyphen, use SEARCH("-",A2).




