<link rel="stylesheet" type="text/css" href="/mirawhite.css">

How to extract numbers from a string in Excel

Updated November 24, 2026

The quickest way is Flash Fill: type the number you want from the first cell in the next column, then press Ctrl+E and Excel fills the rest of the column. For a formula that updates, Microsoft 365 and Excel 2021 can keep only the digits with TEXTJOIN, MID and SEQUENCE. In Google Sheets, =REGEXEXTRACT(A2,"\d+") returns the first number in the cell.

Extract numbers with Flash Fill (Excel 2013 and later)

Flash Fill learns a pattern from the examples you type. It works well when the cells follow the same structure, such as “Order 4512 - Paris” or “Ref: AB-0042”. It needs no formula and is available in every recent version of Excel for Windows and Mac.

When the cells are irregular, for example a number at the start of some cells and at the end of others, type two or three examples before pressing Ctrl+E, then scan the column: Flash Fill does not warn you when it guesses wrong.

  1. Click the cell next to the first text, for example B2.
  2. Type the number exactly as you want it extracted from A2, and press Enter.
  3. Go to Data > Flash Fill, or press Ctrl+E.
  4. Check the results. If some are wrong, correct one of them: Flash Fill updates the others with the new example.

Good to know : Flash Fill writes fixed values: they do not update when the source text changes. If the results are aligned to the left, they are stored as text; convert them with the warning icon > Convert to Number before calculating.

Extract all digits with a formula

This formula works in Microsoft 365, Excel 2021 and Excel 2024. MID splits the text into single characters, multiplying by 1 turns digits into numbers and everything else into errors, IFERROR drops the errors, and TEXTJOIN glues the remaining digits together.

  • The result is text. Add two minus signs in front, =--TEXTJOIN(...), to get a real number, but keep it as text for codes with leading zeros.
  • Every digit in the cell is glued together: “Order 12, qty 3” gives 123, and the decimal point of 4.50 is lost. Use it when the cell holds a single number.
  • In Excel 2019, which has TEXTJOIN but not SEQUENCE, replace SEQUENCE(LEN(A2)) with ROW(INDIRECT("1:"&LEN(A2))) and confirm with Ctrl+Shift+Enter.
=TEXTJOIN("",TRUE,IFERROR(MID(A2,SEQUENCE(LEN(A2)),1)*1,""))

Extract a number between parentheses or after a word

When the number sits between two known characters, cut the text around them. This formula works in every version and returns what is between the first ( and the first ). The two minus signs turn the result into a number.

  • In Microsoft 365 and Excel 2024, TEXTBEFORE and TEXTAFTER are easier to read: =--TEXTBEFORE(TEXTAFTER(A2,"("),")").
  • Number after a marker such as #: =--TEXTAFTER(A2,"#") when nothing follows the number.
  • Number at the end of the text, after the last space: =--TEXTAFTER(A2," ",-1).
  • Replace ( and ) with any other delimiters, such as a dash or a colon.
=--MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1)

Use REGEXEXTRACT in Google Sheets

Google Sheets has regular expressions, which are the most precise way to pull a number out of a string. The result is text, so multiply it by 1 to calculate with it.

  • The pattern above returns the first number, with its minus sign and decimals. Use "\d+" for whole numbers only.
  • =REGEXREPLACE(A2,"\D","") keeps every digit and removes everything else.
  • =SPLIT(TRIM(REGEXREPLACE(A2,"\D+"," "))," ") puts each number of the cell in its own column.
  • Number between parentheses: =REGEXEXTRACT(A2,"\((\d+)\)") returns only the part inside the parentheses.
=REGEXEXTRACT(A2,"-?\d+(?:\.\d+)?")*1

Good to know : Microsoft has added REGEXEXTRACT, REGEXREPLACE and REGEXTEST to Excel for Microsoft 365, where they rolled out gradually from 2024. They are not in Excel 2024, Excel 2021 or older versions; if Excel answers #NAME?, your version does not have them yet, so use the formulas above.

Common problems

  • The result cannot be summed: it is text. Wrap the formula in VALUE() or put -- in front of it.
  • Leading zeros disappear: 00042 becomes 42 once converted to a number. Keep the result as text, or apply a custom format such as 00000.
  • #NAME?: your version lacks SEQUENCE, TEXTJOIN, TEXTAFTER or the REGEX functions. Use Flash Fill or the MID and FIND formula.
  • #VALUE! with the parentheses formula: one cell has no parentheses. Wrap it in IFERROR(...,"") to leave those cells empty.
  • Flash Fill does nothing: give it a second example, or check that File > Options > Advanced > Automatically Flash Fill is turned on.

Extract numbers online with Utiloz

When the numbers come from an invoice, a report or a web page rather than one tidy column, paste the text into Extract numbers from text on Utiloz. Every number comes out on its own line, without thousands separators, ready to paste into a column, with the sum, mean, minimum and maximum underneath.

You choose how the text writes numbers, 1,234.56 or 1 234,56, and the format your spreadsheet expects. Currency symbols are dropped and percentages kept as numbers. Numbers stuck to a letter, such as A4 or mp3, are skipped, a date such as 2026-05-01 gives three numbers, and phone numbers are split into groups. Everything runs in your browser, with no upload and no sign-up.

Frequently asked questions

How do I extract numbers from a cell in Excel using a formula?

In Microsoft 365 or Excel 2021, =TEXTJOIN("",TRUE,IFERROR(MID(A2,SEQUENCE(LEN(A2)),1)*1,"")) keeps only the digits. It glues all digits together, so it suits cells that contain one number.

How do I extract numbers between parentheses in Excel?

Use =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1), or =TEXTBEFORE(TEXTAFTER(A2,"("),")") in Microsoft 365 or Excel 2024. Put -- in front to get a number instead of text.

Does Excel have REGEXEXTRACT?

Only recent Microsoft 365 versions, where it was added along with REGEXREPLACE and REGEXTEST. Excel 2024, Excel 2021 and older versions do not have it, while Google Sheets has had REGEXEXTRACT for years.

How do I extract only numbers from a string in Google Sheets?

=REGEXREPLACE(A2,"\D","") removes everything that is not a digit, and =REGEXEXTRACT(A2,"\d+") returns the first number. Multiply the result by 1 to turn it into a number.

← All guides