To trim text from a specific character in Excel, use the LEFT, RIGHT, and FIND functions together. For example, to remove everything after the first hyphen in cell A2, use =LEFT(A2, FIND("-", A2)-1). To remove everything before the hyphen, use =RIGHT(A2, LEN(A2)-FIND("-", A2)).
Understanding the Core Functions
Excel doesn’t have a single “trim from character” function, but the combination of LEFT, RIGHT, MID, and FIND gives you full control. FIND returns the position of a character (e.g., the hyphen in “ABC-123” is at position 4). LEFT extracts a specified number of characters from the start, RIGHT from the end, and MID from anywhere in the middle. The key is using FIND to locate the character, then subtracting or adding 1 to exclude or include it.
Removing Text After a Character
If your data looks like “Product-2024” and you want just “Product”, use the formula below. With the text in A2:
=LEFT(A2, FIND("-", A2)-1)– returns everything before the first hyphen.- If the hyphen might not exist, wrap it with
IFERROR:=IFERROR(LEFT(A2, FIND("-", A2)-1), A2)
For the last occurrence of a character (e.g., removing after the last slash in a file path), use FIND with a helper: =LEFT(A2, FIND("^", SUBSTITUTE(A2, "/", "^", LEN(A2)-LEN(SUBSTITUTE(A2, "/", ""))))-1). This substitutes the last slash with a caret, then finds that caret.
Removing Text Before a Character
To get the part after the character, use RIGHT with LEN and FIND. For “Product-2024” in A2, to get “2024”:
=RIGHT(A2, LEN(A2)-FIND("-", A2))– removes the hyphen and everything before it.- To include the hyphen, use
=RIGHT(A2, LEN(A2)-FIND("-", A2)+1).
If you need the text between two characters, use MID: =MID(A2, FIND("(", A2)+1, FIND(")", A2)-FIND("(", A2)-1) extracts text inside parentheses.
Using Flash Fill for Quick Trims
Flash Fill (Excel 2013 and later) can trim text without formulas. Type the desired result in the adjacent column, press Ctrl+E (Windows) or Cmd+E (Mac), and Excel fills the rest based on your pattern. For example, if you type “Product” next to “Product-2024”, Flash Fill will extract everything before the hyphen for all rows. This works best when the pattern is consistent, but it’s not dynamic—if the source changes, the extracted text won’t update automatically.
Handling Multiple Characters and Edge Cases
When the character appears multiple times, FIND always returns the first occurrence. To target the second or third, use SEARCH with a start position or combine SUBSTITUTE and FIND. For example, to remove everything after the second comma in “a,b,c”, use =LEFT(A2, FIND("^", SUBSTITUTE(A2, ",", "^", 2))-1). Also, note that FIND is case-sensitive; use SEARCH for case-insensitive matching. If the character isn’t found, FIND returns a #VALUE! error—use IFERROR to handle it gracefully.
Comparing with TRIM and CLEAN
Many users confuse “trim” (removing extra spaces) with “trim from character.” The TRIM function only removes extra spaces from text, not characters. CLEAN removes non-printable characters like line breaks. Neither can remove text after a specific character. For that, you need the LEFT/RIGHT/FIND approach. If you’re dealing with spaces, TRIM is still useful as a preliminary step before extracting text, because extra spaces can shift character positions.
Frequently Asked Questions
Q: How do I remove everything after the last space in Excel?
A: Use a formula that finds the last space: =LEFT(A2, FIND("^", SUBSTITUTE(A2, " ", "^", LEN(A2)-LEN(SUBSTITUTE(A2, " ", ""))))-1). This replaces the last space with a caret, finds its position, and extracts everything before it.
Q: Can I trim from a character in Excel for the web?
A: Yes, the same functions work in Excel for the web. The keyboard shortcuts for Flash Fill are the same, but some advanced functions like LET may be limited in older versions.
Q: What if my character is a wildcard like * or ?
A: In FIND, wildcards are treated as literal characters, so no escaping is needed. For example, =FIND("*", A2) finds the first asterisk. In SEARCH, wildcards are special, so you’d need to use FIND instead.
Q: How do I trim from a character but keep the character itself?
A: Adjust the formula by not subtracting 1. For LEFT, use =LEFT(A2, FIND("-", A2)) to include the hyphen. For RIGHT, use =RIGHT(A2, LEN(A2)-FIND("-", A2)+1).
Q: Is there a way to trim from a character without formulas?
A: Yes, use Text to Columns (Data > Text to Columns) with the character as a delimiter, or use Flash Fill as described above. Text to Columns is static, while Flash Fill is manual but quick.
Related
- D Cell Battery Diameter: Exact Size & Specs
- Windows 10 Shortcut Keys: The Essential List
- Computer Jobs Online Data Entry: Real Work or Scam?
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Payment Schedule: Build One With FormulasTo build a basic loan payment schedule in Excel, enter the annual interest rate, number of monthly payments,…
- Excel Date Minus Date in Years? DATEDIF ExplainedThe direct answer: use =DATEDIF(start_date, end_date, "Y") to get whole years between two dates in Excel. For example,…
- VLOOKUP with Multiple Lookup Values: How to Do ItTo look up a value based on multiple criteria in Excel, you cannot use VLOOKUP directly because it…
- How to Add a Formula to an Entire Row in ExcelTo add a formula across a row in Excel, enter it in the first cell where you want…
- Excel SUBTOTAL COUNTIF: Count Matching Visible RowsExcel has no built-in function that combines SUBTOTAL and COUNTIF: SUBTOTAL can ignore filtered-out rows, but it cannot…
- How to Filter by Number in Excel: A Step-by-Step GuideTo filter by number in Excel, select a cell in your data, choose Data > Filter, open the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.