
π This article includes 1 downloadable practice file β
In this article
Exports from Tally, SAP, bank portals and old software rarely arrive clean. A typical line looks like this:
INV-1001 | Neha Sharma | DELHI
Spaces at both ends, a separator, shouting capitals. Here is how to take it apart in one formula each.
The new text functions (Microsoft 365)
| Function | Formula | Result |
|---|---|---|
| TEXTBEFORE | =TRIM(TEXTBEFORE(A2,"|")) |
INV-1001 |
| TEXTAFTER (last) | =PROPER(TRIM(TEXTAFTER(A2,"|",-1))) |
Delhi |
| Middle part | =TRIM(TEXTBEFORE(TEXTAFTER(A2,"|"),"|")) |
Neha Sharma |
| TEXTSPLIT | =TRIM(TEXTSPLIT(A2,"|")) |
All three parts in three cells |
A negative instance number counts from the end, so TEXTAFTER(A2,"|",-1) is “after the last pipe” no matter how many there are.
The classic helpers still matter
TRIMremoves spaces at both ends and squeezes double spaces inside.PROPER,UPPER,LOWERfix case.SUBSTITUTE(A2,"INV-","")removes a prefix; wrap inVALUEto get a number.CLEANremoves line breaks and invisible characters from PDF copy-paste.
=TRIM(SUBSTITUTE(A2,CHAR(160)," ")).Older Excel?
Without TEXTBEFORE: =TRIM(LEFT(A2,FIND("|",A2)-1)). Or use Data > Text to Columns, or Power Query (covered in the Power Query course), which is the better tool for repeating monthly imports.
Common mistakes
- Cleaning in place. Keep the raw column; clean in a new column so you can always trace back.
- Forgetting the result is text. “1005” from a formula won’t add up until you wrap it in VALUE.
Practice
Download this lesson’s workbook below. The Raw sheet holds five lines from a pipe-separated export. Type your formula in the yellow column; the Check column turns green when the result matches, and the Answers sheet has a working formula for every task.
π Practice files for this article
- πLesson 5 practice workbookFive messy export lines + 8 cleaning tasks.β¬ XLSX Β· 14 KB
Free to use for learning. Files with macros (.bas) are plain text β import them with Alt+F11 β File β Import File, and always test on a copy.
Stuck on a step? Ask a question and the AI answers using this article.