Excel Start End Formula: Extract Text Between Two Points
In this article
To extract text between a start and end point in Excel, use the formula =MID(A1, FIND("start", A1) + LEN("start"), FIND("end", A1) - FIND("start", A1) - LEN("start")). This returns the characters that sit after the start string and before the end string. For example, with "Order #12345 shipped" in A1, start "#" and end " " (the space after the number), the formula returns 12345. The same logic works with cell references for the start and end markers, and you can wrap it in IFERROR to handle missing markers cleanly.
What You'll Need
- Excel 2013 or later (desktop) or Excel for Microsoft 365. The functions used here (MID, FIND, LEN, IFERROR) are available in all modern versions and in Excel for the web.
- A column of text where each cell contains a start marker and an end marker, or you can type the markers directly into the formula.
- Basic familiarity with cell references (A1, B1, etc.). No add-ins or macros are required.
Step-by-Step
- Set up your data. Put the text to parse in column A, starting at A2. In B1 type the start marker (for example
#), and in C1 type the end marker (for example a space or]). If the markers are the same for every row, using cells keeps the formula readable and easy to change. - Write the core formula in B2. Click B2 and enter:
=MID(A2, FIND($B$1, A2) + LEN($B$1), FIND($C$1, A2) - FIND($B$1, A2) - LEN($B$1))
The dollar signs lock the marker cells so you can copy the formula down. - Press Enter and check the result. You should see only the text between the two markers. If you see an error, jump to the Troubleshooting section below before copying down.
- Copy the formula down. Drag the fill handle from B2 down to the last row of your data. Each row now extracts its own start-to-end text.
- Wrap in IFERROR for missing markers. If some rows lack a start or end marker, the formula returns
#VALUE!. Change it to:=IFERROR(MID(A2, FIND($B$1, A2) + LEN($B$1), FIND($C$1, A2) - FIND($B$1, A2) - LEN($B$1)), "")
This returns a blank instead of an error, which keeps your column clean for sorting and filtering. - Convert to values if needed. Select the results, press Ctrl+C, then right-click and choose Paste Special > Values. This replaces the formulas with static text so you can delete the original column or move the results without breaking references.
- Test edge cases. Try a row where the start marker appears twice, a row where the end marker comes before the start marker, and a row with no markers at all. The formula uses the first occurrence of each marker, so repeated starts will return text from the first start to the first end. If you need the second occurrence, you must use a different approach (see Tips).
Common Mistakes
- Forgetting to add LEN(start). FIND returns the position of the first character of the start marker. Without adding LEN, the extracted text includes the start marker itself. Always add
LEN(start)to the start position. - Using the wrong end position. The length argument must be
FIND(end) - FIND(start) - LEN(start). If you omit the subtraction, MID returns too many characters, often spilling into the end marker and beyond. - Not locking marker cells. If you type markers directly into the formula and copy down, Excel adjusts the references. Use absolute references (
$B$1) or hard-code the markers with quotes. - Case sensitivity. FIND is case-sensitive. If your markers might appear in different cases, use SEARCH instead of FIND. SEARCH is case-insensitive and works the same way in this formula.
- Markers that are special characters. Characters like
?,*,~have wildcard meaning in some functions, but FIND and SEARCH treat them literally. However, if you use other text functions, be aware of wildcard behavior. - Expecting the formula to find the last occurrence. FIND and SEARCH always return the first match. If your data has multiple start or end markers, the formula extracts between the first start and the first end, which may not be what you want.
Tips
- Use cell references for markers so you can change them without editing every formula. Name the cells (Formulas > Define Name) to make the formula read like
=MID(A2, FIND(StartMarker, A2) + LEN(StartMarker), FIND(EndMarker, A2) - FIND(StartMarker, A2) - LEN(StartMarker)). - If you need the text after the last occurrence of a marker, combine
SUBSTITUTEwithLENto count occurrences, or useFILTERXMLwith a delimiter. These are advanced and version-dependent; test on a copy first. - To extract text between the same marker used twice (for example between two commas), use
FINDfor the first comma andFINDwith a starting position for the second:=MID(A2, FIND(",", A2)+1, FIND(",", A2, FIND(",", A2)+1) - FIND(",", A2) - 1). - Keep a helper column with the raw text until you have verified the extraction. Once satisfied, convert formulas to values and delete the helper column.
- For large datasets, avoid volatile functions like
INDIRECTin the same formula; MID, FIND, LEN, and IFERROR are not volatile and recalculate efficiently.
Troubleshooting
- #VALUE! error: The start or end marker was not found in the cell. Check for leading or trailing spaces in the marker cells, and confirm the marker exists in the text. Use
TRIMon the marker cells if needed. - Result includes extra characters: Verify the length argument. It should be
FIND(end) - FIND(start) - LEN(start). If you usedFIND(end) - FIND(start), you will include the start marker. - Result is empty or wrong when markers are adjacent: If the end marker immediately follows the start marker, the length becomes zero or negative, and MID returns an empty string or an error. Wrap in IFERROR or add a check:
IF(FIND(end)>FIND(start)+LEN(start), ..., ""). - Formula works in one row but not others: Check that marker cells are locked with
$and that the text column reference is relative (A2, not $A$2). - Case mismatch: Replace FIND with SEARCH if the marker case varies.
- Still not working: Simplify by testing each part separately. In a blank cell, enter
=FIND($B$1, A2)and=FIND($C$1, A2)to see the positions. Then check=LEN($B$1). Once those are correct, rebuild the MID formula step by step.
Frequently Asked Questions
Can I use this formula to extract text between two different characters in the same cell?
Yes. Put the first character in one cell and the second in another, then reference those cells as shown. The formula extracts everything after the first character and before the second.
What is the difference between FIND and SEARCH in this formula?
FIND is case-sensitive and does not accept wildcards; SEARCH is case-insensitive. Both return the position of the first match. Use SEARCH when the marker case might vary.
How do I extract text between the second and third occurrence of a marker?
You need to nest FIND with a start position. For example, to find the second comma: FIND(",", A2, FIND(",", A2)+1). Then use that position in the MID formula. This gets complex; test on a copy of your data.
Why does my formula return #VALUE! for some rows?
Either the start or end marker is missing from that row, or there is a case mismatch. Wrap the formula in IFERROR to return a blank, and check the marker cells for extra spaces.
Can I use this in Excel for the web or Google Sheets?
Yes. MID, FIND, LEN, and IFERROR work the same in Excel for the web and Google Sheets. The menu labels for Paste Special may differ slightly.
Does this formula work if the start and end markers are the same character?
Not directly, because FIND returns the same position for both. You need to find the second occurrence using a nested FIND with a start position, as described in the Tips section.