To pull out the text between two markers — the value inside parentheses, a code between slashes — Excel 365 nests TEXTAFTER and TEXTBEFORE; older versions use the classic MID + FIND combination.
The example
Pull the code from inside the parentheses.
| A | B | |
|---|---|---|
| 1 | Text | Inside ( ) |
| 2 | Order (A123) ready | A123 |
| 3 | Item (B-7) ok | B-7 |
The formula
The text between the parentheses:
How it works
Two slices, inside out:
TEXTAFTER(A2, "(")returns everything after the opening bracket —"A123) ready".TEXTBEFORE(…, ")")then keeps everything before the closing bracket —"A123".- Nesting them isolates exactly what sits between the two markers.
- Use different markers (
"/","[",":") for other wrappers.
Pre-365? The MID/FIND version does the same: =MID(A2, FIND("(",A2)+1, FIND(")",A2)-FIND("(",A2)-1) — start one character after the “(” and take as many characters as sit before the “).”
Try it: interactive demo
Type text with a bracketed part and pick the wrapper characters.
Variations
Legacy MID + FIND
Any version:
Between two of the same character
Text between the 1st and 2nd slash:
After the last marker
Use a negative instance number:
Pitfalls & errors
#N/A or #VALUE! when a marker is missing. If the text has no “(” or “),” the functions error. Wrap in IFERROR for messy data.
FIND is case-sensitive; SEARCH isn’t. For letter markers where case might vary, swap FIND for SEARCH in the legacy formula.
Multiple brackets. The simple nest grabs the first pair. For a later pair, target the right instance with TEXTAFTER’s instance argument.
Practice workbook
Frequently asked questions
How do I extract text between two characters in Excel?
How do I get the text inside parentheses?
What if some cells don't have the markers?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class