Quick Answer & Formula
Excel
Sheets
Intermediate
Modern: =TEXTBEFORE(TEXTAFTER(A2, "("), ")") | Classic: =MID(A2, FIND("(", A2)+1, FIND(")", A2)-FIND("(", A2)-1) In modern Excel: =TEXTBEFORE(TEXTAFTER(A2, "("), ")"). In classic Excel: =MID(A2, FIND("(", A2)+1, FIND(")", A2)-FIND("(", A2)-1).
How to Extract Text Between Parentheses or Characters in Excel
When data contains embedded codes (e.g. "Apple Inc. (AAPL)" or "Project Alpha [PRJ-102]"), you often need to isolate the code inside the delimiters.
Method 1: Modern Formula (Excel 365 & Google Sheets)
=TEXTBEFORE(TEXTAFTER(A2, "("), ")")
How it works:
TEXTAFTER(A2, "(")discards everything before the open parenthesis $\rightarrow$"AAPL)".TEXTBEFORE(..., ")")keeps everything before the close parenthesis $\rightarrow$"AAPL".
Method 2: Classic Formula (Universal MID & FIND)
=MID(A2, FIND("(", A2) + 1, FIND(")", A2) - FIND("(", A2) - 1)
Example Extraction Table
| Source String (Col A) | Target Enclosure | Formula | Extracted Result |
|---|---|---|---|
| Apple Inc. (AAPL) | ( ) | =TEXTBEFORE(TEXTAFTER(A2, "("), ")") | AAPL |
| Microsoft Corp. (MSFT) | ( ) | =TEXTBEFORE(TEXTAFTER(A3, "("), ")") | MSFT |
| Invoice [INV-9821] Final | [ ] | =TEXTBEFORE(TEXTAFTER(A4, "["), "]") | INV-9821 |
| ID-4920-US | - - | =TEXTBEFORE(TEXTAFTER(A5, "-"), "-") | 4920 |
?
Frequently Asked Questions
How do I extract text between square brackets [ ] or hyphens - - ?
Replace the parentheses in the formula with your target delimiter: =TEXTBEFORE(TEXTAFTER(A2, "["), "]").