To extract certain text from a cell in Excel, you usually combine a few core text functions, depending on where the text is located and how predictable the pattern is.

Core idea in one line

Use LEFT , RIGHT , MID with helpers like SEARCH / FIND / LEN / TEXTBEFORE / TEXTAFTER / REGEXEXTRACT (if available) to pull out exactly the text you want from a cell.

Basic building blocks

These classic functions extract a fixed number of characters.

  • =LEFT(text, num_chars) – gets characters from the start of the cell.
    Example: =LEFT(A2,4) returns the first 4 characters of A2.
  • =RIGHT(text, num_chars) – gets characters from the end of the cell.
    Example: =RIGHT(A1,5) returns the last 5 characters.
  • =MID(text, start_num, num_chars) – gets characters from the middle.
    Example: =MID(A5,7,3) returns 3 characters starting at position 7.

Use these when you know exactly where and how many characters you need.

Extract text before or after a character

Often, you want “everything before/after a dash, comma, @, space, etc.” rather than a fixed length.

1. Text before a character

Pattern: “Get everything before X”.

Classic formula pattern:

excel

=LEFT(A2, SEARCH("-", A2) - 1)
  • Pulls all characters in A2 before the first -.
  • Works similarly for commas, spaces, etc. (change "-" to "," or " ").

Example with an email: username before @.

excel

=IFERROR(LEFT(A2, SEARCH("@", A2) - 1), "")

This returns the part before @ (the username).

2. Text after a character

Pattern: “Get everything after X”.

One common pattern uses RIGHT + LEN + FIND/SEARCH :

excel

=RIGHT(A1, LEN(A1) - FIND(".", A1))
  • FIND(".", A1) gives the position of ".".
  • LEN(A1) - FIND(".", A1) gives how many characters are after the dot.
  • RIGHT then returns that many characters from the end.

A username/domain example: get the domain after @.

excel

=IFERROR(
  RIGHT(A2, LEN(A2) - SEARCH("@", A2) - LEN("@") + 1),
  ""
)

This returns everything after the @.

Modern shortcut functions (if your Excel has them)

Newer Excel versions (Microsoft 365, Excel for the web, etc.) add TEXTBEFORE , TEXTAFTER , and TEXTSPLIT , which make many tasks easier.

  • =TEXTBEFORE(text, delimiter) – everything before a delimiter.
  • =TEXTAFTER(text, delimiter) – everything after a delimiter.
  • =TEXTSPLIT(text, delimiter) – splits into multiple pieces you can pick with INDEX.

Examples:

  • Before the first dash:

    excel
    
    =TEXTBEFORE(A2, "-")
    
  • After the first dash:

    excel
    
    =TEXTAFTER(A2, "-")
    

These are more flexible (you can control which occurrence to use, what to return if not found, etc.).

Extracting numbers or letters from mixed text

Sometimes you have product codes like "ABC-12345" and want just the numbers or just the letters.

1. Using REGEX (if available)

Some newer Excel builds include REGEXEXTRACT (or similar) to dynamically pull patterns.

  • Extract numbers from a cell:

    excel
    
    =REGEXEXTRACT(A1, "\d+")
    

This returns the first sequence of digits in A1.

  • Extract letters:

    excel
    
    =REGEXEXTRACT(A1, "[A-Za-z]+")
    

These formulas are powerful for complex patterns like “pack sizes,” “dimensions,” or mixed codes.

2. Without REGEX (traditional Excel)

There are longer array formulas using MID + ROW + FIND or ISNUMBER to strip only letters or only numbers.

Example concept: loop through each character with MID and keep only letters using FIND against the alphabet, then join them back with TEXTJOIN.

excel

=TEXTJOIN(
  "",
  TRUE,
  IF(
    ISNUMBER(FIND(MID(A1, ROW(INDIRECT("1:"&LEN(A1))), 1),
                  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")),
    MID(A1, ROW(INDIRECT("1:"&LEN(A1))), 1),
    ""
  )
)

This returns only the alphabetic characters from A1.

Handling varying lengths and messy real-world strings

Real data usually has different lengths and unpredictable patterns, so you combine several functions.

Typical strategies:

  • Use SEARCH/FIND to locate key characters (dash, comma, space, @).
  • Wrap your formulas in IFERROR to avoid error messages when the pattern doesn’t exist.
  • Use SUBSTITUTE to clean or simplify the text before extracting.

Example: remove a fixed phrase and then trim and cut:

excel

=LEFT(
  SUBSTITUTE(SUBSTITUTE(A1,"XYZ Description",""),":",";"),
  LEN(TRIM(SUBSTITUTE(SUBSTITUTE(A1,"XYZ Description",""),":",";")))-1
)

Here, SUBSTITUTE removes unwanted text and changes : to ; before extraction.

A quick “recipe” style guide

Think of it like different “recipes” depending on what you want:

  • “I know I need the first 3 characters” → LEFT(A1,3).
  • “I need the last 4 characters” → RIGHT(A1,4).
  • “I need 5 characters starting at position 7” → MID(A1,7,5).
  • “I want everything before a dash” → LEFT(A1,SEARCH("-",A1)-1) or TEXTBEFORE(A1,"-").
  • “I want everything after a dot/@/dash” → RIGHT(A1,LEN(A1)-FIND(".",A1)) or TEXTAFTER(A1,".").
  • “I want just numbers/letters from a messy string” → REGEXEXTRACT where available, or longer MID+TEXTJOIN patterns.

Small HTML table of formula patterns

html

<table>
  <thead>
    <tr>
      <th>Goal</th>
      <th>Example formula</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>First N characters</td>
      <td>=LEFT(A1, 4)</td>
    </tr>
    <tr>
      <td>Last N characters</td>
      <td>=RIGHT(A1, 5)</td>
    </tr>
    <tr>
      <td>Middle text (fixed start & length)</td>
      <td>=MID(A1, 7, 3)</td>
    </tr>
    <tr>
      <td>Text before a dash</td>
      <td>=LEFT(A1, SEARCH("-", A1) - 1)</td>
    </tr>
    <tr>
      <td>Text after a dot</td>
      <td>=RIGHT(A1, LEN(A1) - FIND(".", A1))</td>
    </tr>
    <tr>
      <td>Username before @</td>
      <td>=IFERROR(LEFT(A2, SEARCH("@", A2) - 1), "")</td>
    </tr>
    <tr>
      <td>Domain after @</td>
      <td>=IFERROR(RIGHT(A2, LEN(A2) - SEARCH("@", A2) - LEN("@") + 1), "")</td>
    </tr>
    <tr>
      <td>Before delimiter (new versions)</td>
      <td>=TEXTBEFORE(A1, "-")</td>
    </tr>
    <tr>
      <td>After delimiter (new versions)</td>
      <td>=TEXTAFTER(A1, "-")</td>
    </tr>
    <tr>
      <td>Numbers via regex (if available)</td>
      <td>=REGEXEXTRACT(A1, "\d+")</td>
    </tr>
  </tbody>
</table>

All these patterns reflect commonly taught ways to extract text from cells using Excel’s substring functions and newer text tools.

Information gathered from public forums or data available on the internet and portrayed here.