Extract Numbers From Text in Excel (Invoice Numbers, Amounts, Phone Numbers)

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 min read

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
  1. When the position is predictable: LEFT, MID, TEXTAFTER
  2. All the digits, wherever they are (Excel 365)
  3. A specific number pattern: REGEXEXTRACT (newest Excel 365)
  4. No formulas at all: Flash Fill
  5. Where people go wrong
  6. Practice

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), ""))
  1. SEQUENCE(LEN(A2)) makes positions 1, 2, 3… up to the length.
  2. MID(A2, …, 1) splits the text into single characters.
  3. -- turns digits into numbers and everything else into errors.
  4. IFERROR(…, "") drops the errors; TEXTJOIN glues 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.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong

Leave a Reply

Your email address will not be published. Required fields are marked *