Excel Extract Number from String

“excel extract number from string” comes up constantly, so this page leads with the exact answer, gives you a tool to try it on your own numbers, and only then explains the detail. Everything works in Excel on Windows and Mac and maps almost one-to-one to Google Sheets. Copy the answer above and get back to work, or read on to turn a one-off fix into something you never have to look up again.

Exact answer

In Excel: in Microsoft 365, =TEXTJOIN("",TRUE,IFERROR(MID(A2,SEQUENCE(LEN(A2)),1)*1,"")) walks the string one character at a time and keeps only the digits.

On this page7
ƒxText to Columns SplitterLive
Columns found
3

3 rows

Ada LovelaceLondon1815
Grace HopperNew York1906
Alan TuringLondon1912
Runs entirely in your browser — your data never leaves this page.
=TEXTJOIN("",TRUE,IFERROR(MID(A2,SEQUENCE(LEN(A2)),1)*1,""))
Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

Need it as an auditable file?

Ships inside the linked template — formula-driven, unlocked, audit-ready.

View template

What this does

The formula tests each character in turn: MID with SEQUENCE splits the cell into single characters, multiplying by 1 turns a digit into a number and raises an error for anything else, IFERROR discards the errors, and TEXTJOIN glues the survivors back together. The result is text, so wrap it in VALUE when it has to be used as a number, and remember every digit in the cell is kept — a string with two separate numbers comes back as one run of digits. Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “excel extract number from string”. Start on a copy or a tiny sample, keep the affected cells visible, and compare the result with the tool above before you touch the real workbook. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. The point is a calculation you can defend to a CFO or an auditor, but the practical win is that someone else can open the file and understand what happened without asking you.

A worked example

A2 holds "Invoice 2291 approved". The formula returns 2291 as text; =VALUE(TEXTJOIN("",TRUE,IFERROR(MID(A2,SEQUENCE(LEN(A2)),1)*1,""))) returns the number 2291. For "Order 12 of 34", the same formula returns 1234, which is the behaviour to design around rather than be surprised by. Reference numbers arrive glued to descriptions from every export in the world, and the difference between a number and text that looks like one decides whether the join downstream works at all. One habit worth forming early: name the cells that hold your inputs, so the formula reads in plain language instead of a string of cell addresses. A reviewer — or you in three months — can then follow the logic without decoding what B7 and D2 were supposed to mean, which is most of what makes a sheet maintainable.

In Google Sheets

Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. If you take one thing from this page on “excel extract number from string”, make it the habit rather than the keystrokes: set the problem up with labelled inputs, reference those cells, and let Excel do the recomputing. Bookmark the page for the syntax, but do the example once in a blank sheet and check it against the tool above — five minutes of hands-on practice fixes the method in memory far better than re-reading, and it surfaces the small snags while they are still harmless. After that the technique is genuinely yours: faster than searching for it again, and reliable enough to drop into work that other people depend on.

Common mistakes

  • Applying the digit-walk to strings that contain several numbers and getting them silently concatenated.
  • Losing the decimal point and the minus sign: both are non-digits, so 12.50 comes back as 1250.
  • Converting a reference code such as 00427 to a number and dropping its leading zeros.
  • Trusting Flash Fill without checking the whole column — it infers a pattern from the first rows and applies it everywhere.

Frequently asked questions

What if I do not have Microsoft 365?

Replace SEQUENCE(LEN(A2)) with ROW(INDIRECT("1:"&LEN(A2))) and confirm the formula with Ctrl+Shift+Enter, or use Flash Fill.

How do I keep the decimal point?

Test for digits and the separator together, or locate the number with FIND and take a fixed-width MID rather than filtering character by character.

How do I extract the text and drop the numbers instead?

Invert the test: keep the characters where the multiplication fails, which is the same formula with IF(ISERROR(...)) around the character.

Does the result sort correctly?

Only after VALUE converts it. Text digits sort 1, 10, 2 rather than 1, 2, 10.

Other ways people ask this

This is also commonly searched as “extract a number from a string in excel”, “how to extract numbers from a string in excel”, “excel extract numbers from string” and “how to extract number from string in excel”. They describe the identical operation, so you are in the right place no matter how you phrased it.

Why do people search for this in so many different ways?

Because the same task has many names. “extract a number from a string in excel”, “how to extract numbers from a string in excel”, “excel extract numbers from string” all point at the one operation explained on this page, which is why they all lead here.