How to Extract Text Before or After a Specific Symbol in Excel
Use FIND to locate the position of a symbol, then combine it with LEFT and MID to extract the text before or after the symbol, and handle cases where the symbol appears multiple times or cannot be found. Include formula examples, operation steps, and an item-by-item checklist.
Key points of this article
- When the symbol appears only once, use LEFT with FIND to get the content before it, and MID with FIND to get the content after it.
- When the symbol appears multiple times, first find the position of the last symbol, then extract, so the result is more stable.
- Newer versions of Excel can use TEXTBEFORE and TEXTAFTER directly, with shorter formulas; older versions need to combine FIND.
- Wrapping the formula in IFERROR prevents error values from appearing when a cell does not contain the symbol.
- Before extracting, check whether the symbol is full-width or half-width, as this is a common cause of incorrect results.
Many people have a column of data like "Zhang San-Sales Department-2024" and only want to keep the name before the "-", or only the year at the end. This kind of problem is essentially a spreadsheet formula problem, not a document export problem. Just by knowing a few text functions, you can split out the content on either side of the symbol.
This article is for people who often organize spreadsheets and extract information from a piece of text. After reading it, you should be able to write extraction formulas for three cases: the symbol appears only once, the symbol appears multiple times, and the symbol cannot be found. You should also know where to check when the result is wrong. All of the examples below use the same case: cell A2 contains "Zhang San-Sales Department-2024", and the separator is the English hyphen "-".
How do I extract the text before and after a symbol? In short: use FIND to locate the symbol's position, then use LEFT or MID to extract; in newer versions of Excel, you can use TEXTBEFORE and TEXTAFTER directly.
| Your situation | Recommended Practices | Cause |
|---|---|---|
| The symbol appears only once; I want the content before the symbol. | LEFT plus FIND | All common versions are supported, and the syntax is fixed. |
| The symbol appears only once; I want the content after the symbol. | MID plus FIND | Start extracting from the character right after the symbol, without needing to calculate the total length. |
| The symbol appears multiple times; I want the content before and after the last occurrence of the symbol. | First calculate the position of the last character, then use LEFT or MID to extract it. | Using FIND directly can only locate the first occurrence of a character, so the result would be truncated incorrectly. |
| Using the new version of Excel, I want to write it all in one step. | TEXTBEFORE, TEXTAFTER | The syntax is short, but the older versions don't have these two functions. |
| I need to process multiple spreadsheets in a folder | First merge the data with Power Query, then apply the formula above. | Manual copy-and-paste easily misses rows, but once merged, the formula only needs to be written once. |
Before You Begin: Confirm These Points
First, confirm the character of the symbol. The "-" in the table may be a regular English hyphen, or a full-width "-" entered under a Chinese input method. To FIND, these are different characters, so the formula won't locate it. The simple fix is to copy the symbol from the original text into the formula rather than typing one by hand.
First, check how many times the symbol appears. If a cell contains multiple "-", the positions where you cut before and after will differ. "The content before" usually means everything before the first symbol, while "the content after" depends on whether you want everything after the first symbol or only the part after the last symbol. Decide which segment you need before you start writing the formula.
Check whether there are extra spaces. If there are stray spaces on either side of a symbol, the extracted text will also carry leading or trailing spaces. It looks the same, but it will affect later sorting and lookups. You can wrap the formula in the TRIM function.
Confirm your Excel version. TEXTBEFORE and TEXTAFTER are only available in newer versions. If you're not sure, use the LEFT, MID, and FIND approach instead, which works in any version.
Confirm the data volume. With only a few rows, writing a formula manually and filling it down is enough. When the data is spread across multiple files, merging first and then extracting is more reliable than copying file by file.
Steps for extracting the text before and after a symbol in a table
- Open or create a spreadsheet. If you don't have the OmniDoc desktop client yet, you can download it from download.omnidoc.top. In the UniCell spreadsheet, paste the original text into column A, starting at A2.
- In cell B2, enter the "formula before the symbol," for example
=LEFT(A2,FIND("-",A2)-1). It finds the position of the first "-" and takes the characters before it, so the result is "Zhang San". - In cell C2, enter the "formula after the symbol," for example
=MID(A2,FIND("-",A2)+1,LEN(A2)). It starts taking characters after the first "-", so the result is "Sales Dept-2024", which still contains the second symbol. - If you only need the part after the last symbol, first calculate the position of the last symbol in D2 with
=FIND("~",SUBSTITUTE(A2,"-","~",LEN(A2)-LEN(SUBSTITUTE(A2,"-","")))). The "~" here should be a character that never appears in your data. Use the position number returned by this formula with LEFT or MID. - Check the results in the first row. If B2 shows "Zhang San" and C2 shows "Sales Department-2024", the formulas are correct. If you see an error value, go back and check that the symbols match.
- Fill B2, C2 (and D2 if needed) down to the last row so that all rows use the same rule.
- If the results need to be kept long-term, copy the result columns and paste them as values over the originals. This prevents the results from breaking if column A is later deleted or moved.
- Save the spreadsheet and compare a few rows against the original text to confirm that the extraction positions are as expected.
Verify item by item when finished
| Checklist items | How do you see it? | What should I do if I have a problem? |
|---|---|---|
| Is the result cropped at the correct position? | Compare against the original text and randomly check 3 to 5 lines. | Check whether a symbol appears multiple times, and if so, use the notation of the last occurrence. |
| Does an error value appear? | The cell displays an error message | Note that this row has no target symbol. Wrap it in IFERROR so that, when nothing is found, the original text is returned. |
| Are full-width and half-width characters consistent? | Do the symbols in the original text look like English dashes? | Replace the symbols in the formulas with characters consistent with the original text, or use SUBSTITUTE to standardize the replacements. |
| Are there spaces before and after? | Place the result between quotes to observe it, or use LEN to count the length. | Wrap the entire formula with TRIM |
| Do the numbers change their appearance? | "001" turns into "1", or the date format gets messed up | Set the target column to text format before extracting, then paste the original text. |
The IFERROR syntax example is =IFERROR(LEFT(A2,FIND("-",A2)-1),A2). This way, cells without symbols will display the original text directly, making it easy for you to spot the special rows at a glance.
📊 Core Comparison
| Method | Writing example (before the symbol) | Suitable situations |
|---|---|---|
| LEFT plus FIND | =LEFT(A2,FIND("-",A2)-1) | The symbol appears only once, or only the first symbol is needed. |
| SUBSTITUTE plus FIND | First use SUBSTITUTE to locate the last symbol | The symbol appears multiple times, so split it by the last occurrence of the symbol. |
| TEXTBEFORE | =TEXTBEFORE(A2,"-") | New Excel: I want to do it in one step, and be able to use a negative number to specify which occurrence of a symbol to use. |
| Power Query | After merging multiple tables, use the Split Column feature to split by symbol. | Multiple files, large data volume, needs to be executed repeatedly on a schedule |
❓ Frequently Asked Questions (FAQ)
1. The symbol appears several times in the middle, how do I take only the second one?
You can specify which occurrence to replace in SUBSTITUTE. For example, replace the second "-" with "~", then use FIND to locate the position of "~". In newer versions of Excel, TEXTBEFORE and TEXTAFTER also support specifying which occurrence of a delimiter to use, where a negative number counts from the end.
2. If a paragraph has no fixed markers, how do I extract a specific piece of text from it?
If the text has fixed keywords before and after it, you can use SEARCH to find the position of each keyword, then use MID to extract the content between the two keywords. SEARCH is case-insensitive, so it works well with English text. When it can't find a keyword, it also returns an error, so you need to wrap it with IFERROR as a fallback.
3. The extracted values are numbers, so why can't they be summed directly?
Extraction results in the table default to text. They look like numbers but don't take part in calculations. You can convert them with the VALUE function, or change the target column to a numeric format in the data options. Before converting, first check that the numbers contain no non-numeric characters such as commas or spaces.
4. Extracting specific content from multiple Excel files: do I have to copy them one by one?
When the data volume is small, you can process the files one by one. When there are many files, it is recommended to first put all the tables in the same folder, use Power Query to merge them into one table, and then apply the formulas above to the merged columns. This way, when the data is updated later, you only need to refresh once.
5. After extracting the text around the symbols, how do I confirm no lines were missed?
Add a column to the original table that counts the number of symbols, then compare it with the number of extracted rows. When the counts don't match, it is usually because some rows use different symbol notations or the data contains blank lines.
📝 Summary
Extracting the text before and after a delimiter comes down to first using FIND to locate the symbol's position, then using LEFT or MID to pull out the text. When the symbol appears multiple times, locate the last occurrence first. After writing the formula, check for full-width vs. half-width characters, error values, and extra spaces, and the results will be reliable.


