Function Problems

How to Extract Text Before the First Comma in Excel

Elise WilliamsElise Williams Nov 2, 2026 874 views

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.

How to Extract Text Before the First Comma in Excel
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.
Before you start

Ensure your dataset is organized in a single column and create an empty adjacent column to output your newly extracted text.

Solution 1Recommended

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.

1
Select the Destination Cell

Click on cell B2 (or the first cell in your blank destination column) where you want the extracted text to appear.

2
Enter the Extraction Formula

Type the formula: =IFERROR(LEFT(A2,SEARCH(",",A2)-1),A2) into the formula bar.

3
Apply and Fill Down

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 LEFT, SEARCH, and IFERROR Formula
Formula Breakdown: SEARCH finds the comma's numerical position, LEFT pulls the characters up to that position, and IFERROR ensures values without commas remain completely unchanged instead of returning a #VALUE! error.
Advanced Text Processing

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. 1. Open Data: Launch WPS Spreadsheet and open the document containing your text data.
  2. 2. Select Target Cell: Click on the destination cell next to your existing text.
  3. 3. Input Formula: Type =IFERROR(LEFT(A2,SEARCH(",",A2)-1),A2) and press the Enter key.
  4. 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.
Fully compatible with Microsoft Excel formulas, functions, and file formats.Intuitive and user-friendly interface for easy data manipulation.Lightweight software architecture ensuring fast processing for large datasets.
microsoft office alternative - wps office

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).