Home  /  Blog  /  Date & Text
Date & Text

Extract Numbers from Text in Excel — With Examples (TEXTJOIN, TEXTBEFORE, Flash Fill)

By admin 30 November 2026 Date & Text

Your column says “SKU-10492” and you need 10492. Or “Order 1234-A” and you need 1234 — as a number, so it adds up. There is no single EXTRACTNUMBER function in Excel, but there is one formula that does the job: it reads every character in the cell, keeps the digits, and drops the rest. This guide gives you that formula first, then runs it on six codes, so you can check each answer yourself — plus the fix that turns the result from text into a real number, the marker method for a number after “Order #”, and the two honest limitations: two numbers in one cell join into one, and a decimal point is lost.

Quick takeaway: one formula keeps the digits and drops the rest.

  • =TEXTJOIN("", TRUE, IFERROR(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)+0, "")) — all the digits, in order.
  • Wrap it in VALUE() to get a real number: =VALUE(...).
  • A number after a marker: =VALUE(TEXTBEFORE(TEXTAFTER(A2, "#"), "-")).
  • No formula at all: Flash Fill, Ctrl+E.
  • Two numbers in one cell join into one, and a decimal point is lost — know that first.
Extract Numbers from Text in Excel — With Examples (TEXTJOIN, TEXTBEFORE, Flash Fill)

The Formula — All the Digits, in Order

=TEXTJOIN("", TRUE, IFERROR(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)+0, ""))

Read it from the inside out. MID(A2, ROW(...), 1) takes the cell one character at a time — first character, second character, all the way to the end. Adding 0 to a character turns a digit into a number and turns a letter into an error. IFERROR(..., "") replaces every error with nothing. TEXTJOIN("", TRUE, ...) joins what is left — the digits — into one piece of text. In Microsoft 365 it works as written; in older Excel, enter it with Ctrl+Shift+Enter.

The Worked Table — Six Codes

Every example below uses the same six codes. Every result was checked against them.

Code in A2Formula resultAs a number (VALUE())
SKU-104921049210,492
Order 1234-A12341,234
AB12CD3412341,234
Price $47.5047504,750
UKCAR02002020
INV-2026-00422026004220,260,042

Read the rows. “SKU-10492” gives 10492 — the dash is dropped, the digits stay in order. “Order 1234-A” gives 1234. And the last three rows are the ones to study, because they are the limitations — the next two sections cover them.

The Result Is Text — VALUE() Makes It a Number

The formula returns text, even when the characters are digits. The result looks like 10492, but it will not add up or sort as a number — it is the text “10492”, not the number 10492. Wrap the formula in VALUE() to convert it:

=VALUE(TEXTJOIN("", TRUE, IFERROR(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)+0, "")))

And the leading-zero row shows why the distinction matters. “UKCAR020” gives the text “020” — but VALUE("020") is 20, and the zero is gone. If the zero is part of a code, keep the result as text and do not convert it. If it is a number you need to add, convert it and accept that the zero goes.

Two Numbers in One Cell Join Into One

The formula keeps every digit in the cell, in order — it does not know where one number ends and the next begins. “AB12CD34” gives 1234, not 12 and 34. “INV-2026-0042” gives 20260042, not 2026 and 0042. If you need the numbers separately, this is not the formula — split the cell first with TEXTSPLIT, or pull each number after its own marker with TEXTBEFORE and TEXTAFTER.

A Decimal Point Is Lost

A decimal point is not a digit, so the formula drops it. “Price $47.50” gives 4750, not 47.50. If the number has a decimal point and the point matters, do not use this formula — pull the number after its marker instead, with the point included, as the next section shows.

A Number After a Marker — TEXTAFTER and TEXTBEFORE

When the number sits after a label like “Order #”, take what follows the marker, then cut it at the next delimiter. For “Order #1234-A”:

=VALUE(TEXTBEFORE(TEXTAFTER(A2, "#"), "-"))
StepFormulaResult
After the marker=TEXTAFTER(A2, "#")1234-A
Before the dash=TEXTBEFORE(TEXTAFTER(A2, "#"), "-")1234
As a number=VALUE(TEXTBEFORE(TEXTAFTER(A2, "#"), "-"))1,234

TEXTAFTER and TEXTBEFORE are available in Microsoft 365 and Excel 2024. They do the same job without counting positions — and because the cut happens at a delimiter, a decimal point inside the number survives: TEXTAFTER on “Price $47.50” with the marker “$” gives “47.50”, point included.

Fixed Positions — LEFT, RIGHT, MID

When the number always sits at the same place in the code, the older functions are simpler. For the code UKCAR020 — two letters, three letters, three digits:

GoalFormulaResult
First 2 characters=LEFT(A2, 2)UK
Middle 3 characters=MID(A2, 3, 3)CAR
Last 3 characters=RIGHT(A2, 3)020
As a number=VALUE(RIGHT(A2, 3))20

LEFT takes characters from the start, RIGHT from the end, MID from any position. The same text rule applies: the result is text until VALUE() converts it.

No Formula at All — Flash Fill

Type the answer for the first row or two, select the column, and press Ctrl+E. Flash Fill sees the pattern and fills the rest — no formula, no version requirement. It is the fastest option for a one-off cleanup, and the worst for a sheet that keeps changing, because it does not recalculate: if the source text changes, the filled values stay as they were.

Common Mistakes

MistakeWhat happensFix
You used the result in a SUMIt adds to 0 — the result is text, not a numberWrap the formula in VALUE()
You expected two numbers to stay separate“AB12CD34” gives 1234 — one numberSplit with TEXTSPLIT, or pull each number after its own marker
You expected the decimal point to survive“Price $47.50” gives 4750Use TEXTAFTER with the marker, so the point is inside the cut
You converted a code with a leading zero“020” becomes 20 — the zero is goneKeep the result as text if the zero is part of the code
You used TEXTBEFORE in old Excel#NAME? — the function does not exist thereUse LEFT/RIGHT/MID, or Power Query
You used TEXTSPLIT with no free cells#SPILL! — the pieces have nowhere to goClear the cells to the right first

Frequently Asked Questions

How do I extract numbers from text in Excel? =TEXTJOIN("", TRUE, IFERROR(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)+0, "")) — it reads every character, keeps the digits, and drops the rest. Wrap it in VALUE() to get a real number.

How do I extract only the numbers after a word in Excel? =VALUE(TEXTBEFORE(TEXTAFTER(A2, "#"), "-")) for a number after “Order #” and before a dash — adjust the marker and the delimiter to your own text.

Why does my extracted number not add up? The result is text, not a number. Wrap the formula in VALUE(), or check that the cell is formatted as General and the value is a number.

How do I extract numbers from a cell with two numbers in it? The digit-keeping formula joins them into one — “AB12CD34” gives 1234. Split the cell with TEXTSPLIT first, or pull each number after its own marker.

Does the formula keep decimal points? No — a decimal point is not a digit, so “Price $47.50” gives 4750. Use TEXTAFTER with the marker so the point is inside the cut.

How do I extract numbers without a formula? Flash Fill: type the answer for the first row or two, select the column, press Ctrl+E. It does not recalculate, so use it for a one-off cleanup.

That is how to extract numbers from text in Excel: one formula reads every character and keeps the digits — =TEXTJOIN("", TRUE, IFERROR(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)+0, "")) — and VALUE() turns the result into a real number. On the codes in this guide, that one pattern answers every question: “SKU-10492” gives 10492, “Order 1234-A” gives 1234, and “UKCAR020” gives the text “020”, which is 20 as a number. Remember the two things that catch everyone once: the result is text until VALUE() converts it, and the formula keeps every digit in the cell — so two numbers join into one and a decimal point is lost. When the number sits after a label, TEXTAFTER and TEXTBEFORE are the cleaner tool, and when the number sits at a fixed position, LEFT, RIGHT and MID are the simplest. From here, the next function worth learning is the one this one sits next to — the combine text guide for joining pieces back together — and the full learning order for the whole site is on the Excel Formulas hub and the Date & Text topic page.


About admin

Author of Excel formula guides on this blog.

View all guides by admin →

Keep Learning

Related guides