How to Extract Root Category Before the First Delimiter in Excel
Question details
The user wants to extract the root category text that appears before the first double-colon delimiter (::) in an Excel calculated column, ensuring that original values without delimiters remain unaffected.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating a calculated column to clean up or categorize data containing specific text delimiters.
- Observed behavior
- The user needs to isolate the root category string before the delimiter without returning errors for cells that don't contain the delimiter.
Ensure your target column data is formatted consistently. Identify the exact character or string that separates your text (e.g., a double-colon '::', comma, or hyphen) so you can correctly adjust the formula.
Use Text Extraction Formula with TRIM, LEFT, and SUBSTITUTE
This method uses a combination of built-in Excel text functions to cleanly isolate the string before the delimiter without breaking cells that lack delimiters.
By replacing the target delimiter with a large block of blank spaces, extracting the leftmost portion of the new string, and then removing the extra spaces, this formula safely retrieves the root text.
It gracefully handles cells that do not contain the delimiter by simply returning the original text unchanged.
Click on the first blank cell in your calculated column where you want the extracted root category to appear.
Type the formula =TRIM(LEFT(SUBSTITUTE([@Category],"::",REPT(" ",255)),255)) into the formula bar. Replace [@Category] with your actual cell reference (for example, A2).
If your text uses a different delimiter like a comma (,) or a hyphen (-), change the "::" in the formula to match your specific delimiter.
Press Enter to execute the formula. Click the cell again, hover over the bottom-right corner until the cursor becomes a cross, and drag it down to apply the extraction to the rest of the column.
Extract Text and Analyze Data Easily with WPS Spreadsheet
WPS Spreadsheet fully supports Excel's advanced text functions, including TRIM, LEFT, and SUBSTITUTE. You can easily clean, organize, and extract your data without worrying about formula compatibility.
- 1. Open your data file: Launch WPS Spreadsheet and open the document containing your category data.
- 2. Input the formula: Select a blank cell next to your text data and paste the formula =TRIM(LEFT(SUBSTITUTE(A2,"::",REPT(" ",255)),255)).
- 3. Auto-fill the column: Press Enter, then double-click the small green fill handle at the bottom-right corner of the cell to instantly apply the formula down the entire column.

Frequently Asked Questions
Can I use Text to Columns instead of a formula to extract the root category?
Yes. You can highlight your data, go to the Data tab, and select 'Text to Columns'. Choose 'Delimited', enter your custom delimiter (like '::'), and finish. However, unlike a formula, this will physically split your source data into separate columns.
How do I extract text after the first delimiter instead of before it?
To extract text after the delimiter, you can use a combination of RIGHT, LEN, and FIND functions. For example: =RIGHT(A2, LEN(A2) - FIND("::", A2) - 1).
What if my cell contains multiple different delimiters?
If you are dealing with different delimiters (like commas and hyphens in the same column), you may need to nest multiple SUBSTITUTE functions to standardize the delimiter first before extracting, or use the newer TEXTSPLIT function if your version supports it.
Why does the formula use the number 255?
The number 255 is used as an arbitrarily large number that is guaranteed to be longer than the text you want to extract. This ensures the LEFT function safely captures your entire root category word alongside the added blank spaces.




