ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Text
  3. Extract Text Between Two Characters in Excel

Extract Text Between Two Characters in Excel

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To extract text between two characters in Microsoft 365, nest TEXTAFTER inside TEXTBEFORE: =TEXTBEFORE(TEXTAFTER(A2,"("),")") returns what sits between the brackets. In any version, use MID and FIND: =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1). FIND gives the positions of the two characters, and MID takes the text between them.

Key takeaways

  • TEXTBEFORE(TEXTAFTER(A2,start),end) is the easiest way, but needs Microsoft 365 or Excel 2024.
  • The classic formula is MID(text, first position + 1, second position - first position - 1).
  • For two copies of the same character, like dashes, give FIND a start position or use TEXTAFTER's instance number.
  • Wrap the formula in IFERROR, or use TEXTAFTER's if_not_found argument, for rows without the characters.
  • The result is text; wrap it in VALUE if you need a number.
On this page+
  1. The quick way: TEXTBEFORE and TEXTAFTER
  2. The classic way: MID and FIND
  3. Extract text between two of the same character
  4. Handle rows that don't have the characters
  5. FIND vs SEARCH
  6. Extract text between two words
  7. Turn the result into a number
  8. When to use Text to Columns instead
  9. Practise it

To extract text between two characters in Excel, such as a code inside brackets or a year between two dashes, you find where each character sits and take the text in between. In Microsoft 365, TEXTBEFORE and TEXTAFTER do this in one short formula. In every other version, MID and FIND do the same job. This guide explains both, step by step, with the edge cases that trip people up.

All the examples use a product list like this:

A
1Product
2Laptop Stand (SKU-4471)
3Desk Mat (SKU-1093)
4Cable Box (SKU-2280)

The quick way: TEXTBEFORE and TEXTAFTER#

TEXTAFTER returns everything after a character, and TEXTBEFORE returns everything before one. Put one inside the other and you get the text between two characters:

Excel formula
=TEXTBEFORE(TEXTAFTER(A2,"("),")")

Read it from the inside out:

  1. TEXTAFTER(A2,"(") returns SKU-4471), everything after the opening bracket.
  2. TEXTBEFORE(...,")") takes that and returns SKU-4471, everything before the closing bracket.

This is the easiest formula to read and fix. It needs Microsoft 365, Excel 2024 or Excel for the web. In older versions it shows #NAME?, so use MID and FIND instead. The TEXTBEFORE and TEXTAFTER lesson covers both functions in detail.

The classic way: MID and FIND#

MID takes a piece of text from the middle of a cell, and FIND tells it where to start and how much to take. This works in every version of Excel:

Excel formula
=MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1)

MID needs three things: the text, the start position, and the number of characters. Here is how the formula works them out for "Laptop Stand (SKU-4471)":

PartWhat it doesResult
FIND("(",A2)Position of the opening bracket14
FIND(")",A2)Position of the closing bracket23
FIND("(",A2)+1Start one character after the bracket15
23 - 14 - 1Number of characters between the brackets8
MID(A2,15,8)Take 8 characters starting at 15SKU-4471

The -1 in the length is there because you want the characters strictly between the two brackets, not including either one. Fill the formula down and every row works out its own positions, even though the product names have different lengths. See the MID function guide and the FIND function guide for each function's full syntax.

Extract text between two of the same character#

When both characters are the same, such as the dashes in "INV-2024-0042", the second FIND must start searching after the first dash. Otherwise it finds the first dash again.

With TEXTBEFORE and TEXTAFTER, this just works:

Excel formula
=TEXTBEFORE(TEXTAFTER(A2,"-"),"-")

TEXTAFTER returns "2024-0042", and TEXTBEFORE returns 2024.

With MID and FIND, use FIND's optional third argument, the start position:

Excel formula
=MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1)

The first dash is at position 4. FIND("-",A2,5) starts looking at position 5 and finds the second dash at 9. MID then takes 9 - 4 - 1 = 4 characters from position 5: 2024.

For text after the second or third copy of a character, TEXTAFTER has an instance number: =TEXTAFTER(A2,"-",2) returns 0042.

Handle rows that don't have the characters#

If a cell is missing one of the characters, FIND returns #VALUE! and TEXTAFTER returns #N/A. In a real list, a few rows usually break the pattern. Wrap the formula to show a blank instead:

Excel formula
=IFERROR(MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1),"")

TEXTAFTER and TEXTBEFORE also have their own sixth argument, if_not_found, but IFERROR around the whole formula is simpler and covers both functions. To flag the rows instead of hiding them, test first with IF and ISNUMBER, as shown in IF with text conditions.

FIND vs SEARCH#

FIND is case-sensitive, and SEARCH is not. For symbols such as brackets, dashes and @ signs, it makes no difference. When the boundary is a word, such as the text between "Ref:" and "Date:", SEARCH is safer because it matches "ref:" and "REF:" too. SEARCH also accepts wildcards. The guide to FIND and SEARCH in Excel compares them in detail.

Extract text between two words#

The same method works when the boundaries are words rather than single characters. Say A2 holds "Invoice Ref: 7781, due 30 June". To pull out the reference number, use the label and the comma as the two boundaries:

Excel formula
=TEXTBEFORE(TEXTAFTER(A2,"Ref: "),",")

The result is 7781. Include the space after the colon in the first boundary, or the result starts with a space. In older Excel, use SEARCH to find "Ref: " and add its length, 5, to get the start position for MID.

Turn the result into a number#

Every text function returns text, even when the result looks like a number. If you extract "2024" or "4471" and want to add it up or compare it, wrap the formula in VALUE:

Excel formula
=VALUE(TEXTBEFORE(TEXTAFTER(A2,"-"),"-"))

This returns the number 2024. Text numbers sit on the left of the cell by default; real numbers sit on the right, which is a quick way to tell them apart.

When to use Text to Columns instead#

If you need to split every part of the text, not just one piece in the middle, Text to Columns or TEXTSPLIT may be faster. They cut the text at every delimiter in one go. The guide to Text to Columns shows the menu method, and Text to Columns vs TEXTSPLIT compares the two. Formulas are better when the source data keeps changing, because they update automatically. For the common case of email addresses, see how to extract the domain from an email.

Practise it#

The MID and FIND formula looks long, but once you've built it a couple of times it becomes routine. Practise TEXTBEFORE and TEXTAFTER in a live spreadsheet: you type the formula and it checks the result instantly. Then practise FIND and SEARCH to get confident with positions, the part most people find tricky.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Pull the SKU out of the brackets in A2. In B2, use MID with FIND: start one character after (, and take the characters up to ).

fx
ABCD
1
Product
SKU
2
Laptop Stand (SKU-4471)
3
Desk Mat (SKU-1093)
4
Cable Box (SKU-2280)
5
Monitor Arm (SKU-3615)
6
7
8

Tip: Start at FIND("(",A2)+1. The length is FIND(")",A2)-FIND("(",A2)-1.

Practise this in a lesson

LessonTEXTBEFORE and TEXTAFTERSplit emails, "Last, First" names and file paths at a delimiter with TEXTBEFORE and TEXTAFTER, including picking which occurrence to split at.LessonFIND and SEARCHLocate a character or word inside text with FIND or SEARCH, then use that position to split names and pull out order numbers.Function guideMIDPull characters from any position with Excel's MID. Extract IDs, email domains and text between brackets with FIND. Examples and live practice.Function guideFINDLocate a character inside text with Excel's FIND, then use it with LEFT, MID and RIGHT. Case rules, #VALUE! fixes and a live exercise.

Frequently asked questions

How do I extract text between two characters in Excel?

+

In Microsoft 365, use =TEXTBEFORE(TEXTAFTER(A2,"("),")"). In older versions, use =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1). Replace the brackets with your own characters.

How do I extract text between two dashes?

+

Use =TEXTBEFORE(TEXTAFTER(A2,"-"),"-"). For older Excel, find the second dash with FIND("-",A2,FIND("-",A2)+1) and use it as the end position in MID.

Why does my MID and FIND formula return #VALUE!?

+

FIND couldn't find one of the characters in that cell. Check the character is really there, and wrap the formula in IFERROR to show a blank or a message instead.

Is FIND case-sensitive?

+

Yes. FIND treats A and a as different. Use SEARCH instead if you are looking for letters and case doesn't matter. For symbols like brackets and dashes it makes no difference.

Sources

  • MID, MIDB functions - Microsoft Support
  • FIND, FINDB functions - Microsoft Support
  • TEXTAFTER function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. The quick way: TEXTBEFORE and TEXTAFTER
  2. The classic way: MID and FIND
  3. Extract text between two of the same character
  4. Handle rows that don't have the characters
  5. FIND vs SEARCH
  6. Extract text between two words
  7. Turn the result into a number
  8. When to use Text to Columns instead
  9. Practise it

Keep reading

Text· 7 min read

Extract the Domain or Username From an Email in Excel

To extract the domain from an email address, take everything after the @ sign. In Microsoft 365, use =TEXTAFTER(A2,"@"). In any version, use =MID(A2,FIND("@",A2)+1,LEN(A2)). For the username, take everything before the @: =TEXTBEFORE(A2,"@") or =LEFT(A2,FIND("@",A2)-1). Wrap either in IFERROR for cells without an @.

Text· 7 min read

Find the Position of Text in a Cell (FIND and SEARCH)

FIND and SEARCH return the position of some text inside a cell, as a number. =FIND(" ",A2) gives 5 for Dana Whitfield, because the space is the 5th character. FIND is case-sensitive; SEARCH ignores capitals and allows wildcards. Both return #VALUE! when the text isn't there, so wrap them in ISNUMBER to test whether a cell contains a word.

Logic· 6 min read

IF With Text in Excel: Check Words and Partial Matches

To check if a cell equals a word, use =IF(A2="Paid","Done","Chase"). To check if a cell contains a word anywhere, use =IF(ISNUMBER(SEARCH("refund",B2)),"Refund","Other"). SEARCH finds the word's position or returns an error, and ISNUMBER turns that into TRUE or FALSE. Wildcards like * don't work with = inside IF.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free