Excel Formula to Pull Out Text Between Two Characters

Formulas & functions · Updated November 19, 2026

To pull text out from between two characters in Excel, use MID with FIND. If A2 contains Order [Blue Widget] shipped, this formula returns Blue Widget: =MID(A2,FIND("[",A2)+1,FIND("]",A2,FIND("[",A2)+1)-FIND("[",A2)-1). It finds the opening character, then the next closing character, and returns the characters between them.

What “middle text” means in Excel

People use “middle text” to describe a few different tasks. Usually, they mean extracting the text between two markers, such as the words inside parentheses, the value between brackets, or the section between two hyphens. The formula above handles that common case when the markers are present in the same cell.

There is another possible meaning: take a fixed number of characters from a known position. Excel handles that with MID alone. For example, if a code always has the same structure, you can specify its starting position and the number of characters to return. The delimiter-based formula is more adaptable when the text before or after the desired section changes in length.

In this context, the “middle” does not have to be the mathematical center of the cell’s text. It is simply the portion between a starting marker and an ending marker. Decide which interpretation fits the data before choosing a formula.

How the MID and FIND formula works

MID returns a specified number of characters from a text value. Its arguments are the text, the position to start at, and the number of characters to return. FIND returns the position of one text string inside another. In the example, the first FIND locates the opening square bracket, and adding 1 moves the start position past that bracket.

The second FIND locates the first closing bracket after the opening one. The formula subtracts the opening bracket’s position and 1 from that position to calculate the length of the content. The minus 1 excludes the closing bracket. Together, those calculations tell MID exactly which characters to return.

For a sheet where A2:A100 contains entries with one square-bracketed section per cell, use the formula below in B2 and fill it down. For the sample value Order [Blue Widget] shipped in A2, B2 returns Blue Widget.

=MID(A2,FIND("[",A2)+1,FIND("]",A2,FIND("[",A2)+1)-FIND("[",A2)-1)

Using a closing-marker search that starts just after the opening marker matters if the text contains more than one pair of markers. It directs Excel to the first closing bracket after the opening bracket it found, rather than blindly searching from the beginning of the cell.

Change the markers for other text patterns

The formula’s structure stays the same when the delimiters change; replace the square brackets in the formula with the characters that surround the desired text. For example, braces, parentheses, commas, or a phrase can serve as markers. The markers must match the actual contents of the cell, including spaces when a space is part of the boundary.

With product descriptions in A2:A100 that look like Item (large) - in stock, put this formula in B2 and fill down. For A2 equal to Item (large) - in stock, the result is large.

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

If the delimiters are words instead of single characters, use the complete phrase as the search text. For cells in A2:A100 that contain Code: AB-42; status: active, this formula in B2 returns the value between Code: and ; status. The trailing space in the first marker is intentional, so it is not included in the extracted value.

=MID(A2,FIND("Code: ",A2)+LEN("Code: "),FIND("; status",A2,FIND("Code: ",A2)+LEN("Code: "))-FIND("Code: ",A2)-LEN("Code: "))

Here, LEN supplies the length of the starting phrase, so the returned text begins immediately after it. For the example value, the result is AB-42. Check spaces and punctuation carefully when adapting a phrase-based formula.

Use cell references for changeable delimiters

If you might change the delimiters, put them in cells instead of embedding them in the formula. For example, use D1 for the opening marker and E1 for the closing marker, while A2:A100 contains the source text. Enter the formula below in B2 and fill it down. If D1 contains [, E1 contains ], and A2 contains Order [Blue Widget] shipped, the result is Blue Widget.

=MID(A2,FIND(D$1,A2)+LEN(D$1),FIND(E$1,A2,FIND(D$1,A2)+LEN(D$1))-FIND(D$1,A2)-LEN(D$1))

The dollar signs keep the delimiter row fixed when you copy the formula down, while the A2 reference changes to A3, A4, and so on. This is convenient when applying the same extraction to many rows or testing different markers. The formula also uses LEN, so it can accommodate a delimiter longer than one character.

A shorter option in newer Excel versions

Microsoft 365 and Excel 2024 include TEXTAFTER and TEXTBEFORE, which can make a simple delimiter extraction easier to read. The following formula assumes A2:A100 contains text with one bracketed value. Enter it in B2 and fill down. For Order [Blue Widget] shipped in A2, it returns Blue Widget.

=TEXTBEFORE(TEXTAFTER(A2,"["),"]")

TEXTAFTER returns the part after the opening bracket, and TEXTBEFORE then returns the part of that result before the closing bracket. This is concise, but it may not behave the same as the longer formula if a cell has multiple pairs of brackets: by default, these functions work with the first matching delimiter in the relevant text. For more control over repeated delimiters, inspect the data and choose the intended occurrence.

These functions are available in Microsoft 365 and Excel 2024, but not Excel 2021. The MID and FIND approach works in older Excel versions as well, making it a practical choice for workbooks shared with people who may not have the newer functions. Microsoft 365 for Windows is the assumed environment here; the formulas also work in Excel for Mac when the same functions are supported. Excel for the web supports modern formulas, though the availability of a function can depend on the account and update state.

Handle missing delimiters and inconsistent rows

If either marker is missing, the standard FIND-based formula returns an error. This can be useful while cleaning data because it makes unexpected rows visible, but it may be preferable to show a blank when no complete pair is present. For source text in A2:A100, put this version in B2 and fill it down. It returns Blue Widget for the sample bracketed text and a blank for a row where a required marker is absent.

=IFERROR(MID(A2,FIND("[",A2)+1,FIND("]",A2,FIND("[",A2)+1)-FIND("[",A2)-1),"")

IFERROR catches errors from the extraction and substitutes an empty text value. That can make a results column look cleaner, but it also hides the reason extraction failed. If you need to review incomplete records, leave the error visible or use a separate check to identify rows that need correction.

A formula can only extract reliably when the text follows a predictable rule. Watch for missing markers, extra spaces, different punctuation, or a closing marker that appears before the opening one. A blank result does not necessarily mean the source cell is empty; it may mean the markers did not match the formula.

Repeated markers and common pitfalls

When a cell contains several pairs, such as North [A] / South [B], decide which pair you want. The basic formula shown here extracts between the first opening bracket and the first closing bracket after it, so it returns A. It does not automatically extract every bracketed item or choose the last pair. For multiple results, you may need a formula designed for repeated extraction, a helper column, or a different data-cleaning approach.

  • Do not include the markers in the returned text. The starting position adds the length of the opening marker, and the character count excludes the closing marker.
  • Check for spaces. If a space is inside the delimiters, it is part of the result. Use TRIM separately if you need to remove leading or trailing ordinary spaces.
  • Remember that FIND is case-sensitive. For letter-based markers where case should not matter, SEARCH can be used in place of FIND.
  • Keep the markers consistent. Straight quotes in a formula are formula syntax; the delimiter characters inside them must be the characters that actually occur in the cell.

Another common mistake is expecting a formula to identify a semantic “middle” automatically. Excel does not know which phrase is meaningful; it follows the character positions and delimiters you specify. If the source text varies substantially, standardize it first or use a more explicit rule rather than assuming every row has the same pattern.

Fixed-position extraction versus delimiter extraction

Use MID with a fixed starting position when every value has the same layout. For example, if each cell in A2:A100 contains a six-character code and the three-character section always starts at position 2, this formula in B2 returns the three characters beginning there. If A2 is XABCYZ, the result is ABC.

=MID(A2,2,3)

This is simpler than a delimiter formula, but it depends on the position never changing. If a prefix grows or shrinks, the formula may return the wrong characters without showing an error. Delimiter-based extraction is generally better for descriptions or records where the surrounding text changes length but the markers remain stable.

For one-off cleanup, Excel’s Text to Columns feature may be useful when a consistent delimiter divides a whole column into separate fields. It is a data transformation rather than a formula: it places output in adjacent columns and can overwrite existing data if the destination cells are occupied. Formulas are often preferable when results should update as the source text changes.

Frequently Asked Questions

What is the simplest formula to extract text between parentheses?
Use MID with FIND, changing the opening and closing markers to ( and ). For one simple pair of parentheses, the method described above returns the text inside them.

Can Excel pull text between two words?
Yes. Search for the full starting and ending phrases, and use LEN to move past the starting phrase. Match any spaces and punctuation exactly as they appear in the source text.

How do I avoid an error when a marker is missing?
Wrap the extraction formula in IFERROR and choose what to show instead, such as a blank. Keep in mind that this hides all errors from that calculation, not only missing markers.

Does the formula return the last pair of brackets?
No. The formula given targets the first opening marker and the first closing marker after it. A cell with multiple pairs needs a rule for which occurrence to extract and a formula built for that case.

Can I use TEXTBEFORE and TEXTAFTER in every Excel version?
No. They are available in Microsoft 365 and Excel 2024, but not Excel 2021. Use MID and FIND when compatibility with older Excel versions matters.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.