
π This article includes 1 downloadable practice file β
Bank narrations, ERP exports and copied web data hide the numbers you need inside text: βNEFT-HDFC-REF 4471029-Raj Tradersβ, βQty: 12 pcsβ, βRs 12,500 paid on 3rdβ. Excel can pull them out β which method depends on your Excel version and how regular the text is.
In this article
When the position is predictable: LEFT, MID, TEXTAFTER
=RIGHT(A2, 4) ' "INV-2026-0045" β "0045"
=TEXTAFTER(A2, "-", -1) ' last part after the final dash β "0045"
=TEXTBEFORE(TEXTAFTER(A2, "Rs "), " ") ' "Paid Rs 12,500 via UPI" β "12,500"
These return text. Wrap with -- or VALUE() to get a number: =--SUBSTITUTE(TEXTBEFORE(TEXTAFTER(A2,"Rs ")," "),",","") β 12500.
All the digits, wherever they are (Excel 365)
=TEXTJOIN("", TRUE, IFERROR(--MID(A2, SEQUENCE(LEN(A2)), 1), ""))
SEQUENCE(LEN(A2))makes positions 1, 2, 3β¦ up to the length.MID(A2, β¦, 1)splits the text into single characters.--turns digits into numbers and everything else into errors.IFERROR(β¦, "")drops the errors;TEXTJOINglues the digits back together.
βCall 98765 43210 after 6β becomes β98765432106β β notice it also grabbed the 6. That’s the limitation: it collects every digit.
A specific number pattern: REGEXEXTRACT (newest Excel 365)
=REGEXEXTRACT(A2, "[6-9]\d{9}") ' 10-digit Indian mobile
=REGEXEXTRACT(A2, "\d+(\.\d+)?") ' first number, with decimals
=REGEXEXTRACT(A2, "INV-\d{4}-\d+") ' invoice code
Regular expressions describe the shape of what you want, so stray digits elsewhere are ignored. If your Excel doesn’t have REGEXEXTRACT yet, use the methods above or Power Query.
No formulas at all: Flash Fill
Type the number you want next to the first two rows, then press Ctrl+E. Excel guesses the pattern for the rest. Great for one-off cleaning; it doesn’t update when data changes.
Where people go wrong
| Problem | Fix |
|---|---|
| Result looks like a number but SUM ignores it | It’s text β add -- or VALUE() |
| Leading zeros lost (β0045β β 45) | Keep it as text if it’s a code, or format with "0000" |
| Commas break VALUE (β12,500β) | SUBSTITUTE the commas away first |
| Long numbers turn into 9.8765E+09 | Phone numbers are identifiers β keep as text, don’t convert |
Practice
The combo practice workbook below has a Sales sheet of 200 orders and a task for every formula on this page. Type your formula in the yellow column; the check turns green when the answer matches. The Answers sheet has working versions.
More combinations: all formula combos Β· functions used here are explained in the Excel function course.
π Practice files for this article
- πFormula combinations practice workbook50 tasks: lookups, running totals, ranks, top-N, unique counts, FY, age, text extraction, list comparison, weighted averages, ageing, rolling totals, duplicates and working days β with automatic checks.β¬ XLSX Β· 39 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.