To pull only the digits out of a mixed cell in Excel, the most reliable approach is a formula that walks through each character and keeps the numbers. In Excel 365 and Excel 2021 you can do it in one cell with TEXTJOIN, MID, ROW and ISNUMBER; in older versions you need a helper column or a short VBA function. Excel has no built-in "extract digits" button, so you build the result yourself. The steps below cover the modern formula method first, then a fallback for older versions, plus how to handle the result as a real number.

What You'll Need

  • Excel 365, Excel 2021, or Excel 2019 for the array-formula method (2019 needs Ctrl+Shift+Enter).
  • Your source text in a single column, one value per row, with no merged cells.
  • A blank column next to it for the result.
  • For the VBA route: a workbook saved as .xlsm and macro security set to allow macros.

Step-by-Step

  1. Set up your data. Put the mixed text in column A starting at A2. For example A2 might contain "Order AB-4471-XZ". Leave column B empty for the extracted digits.
  2. Enter the modern formula in B2. Type or paste:
    =TEXTJOIN("",TRUE,IFERROR(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)*1,""))
    In Excel 365 this spills and calculates normally. In Excel 2019 press Ctrl+Shift+Enter instead of Enter so it becomes an array formula.
  3. Check the result. B2 should show 4471. The formula takes each character position, tries to multiply the character by 1, keeps only the ones that become numbers, and joins them with no separator.
  4. Fill down. Drag the fill handle from B2 down to the last row of your data, or double-click it. Every row now has its digits extracted.
  5. Convert text to a real number. The result is text, so if you need to sort or calculate, wrap it: =VALUE(B2) in C2, or add *1 to the end of the formula. If a cell has no digits, VALUE returns #VALUE!, so guard it with =IFERROR(VALUE(B2),"").
  6. Copy and paste as values (optional). Select the results, press Ctrl+C, then right-click and choose Paste Special > Values to freeze the numbers and remove the formulas.
  7. Older Excel fallback. If TEXTJOIN is not available, use a helper column: in B2 enter =IFERROR(MID($A2,COLUMN(A1),1)*1,""), drag right across as many columns as the longest string, then in a far column use =TEXTJOIN("",TRUE,B2:Z2) if available, or concatenate the helper cells with &. This is clunky but works in any version.
  8. VBA alternative (any version). Press Alt+F11, insert a module, and add a function that loops through characters and keeps those where IsNumeric is true. Save as .xlsm. Call it like =GetDigits(A2). Only use code you understand or that comes from a trusted source.

Common Mistakes

  • Forgetting the array entry in older Excel. Without Ctrl+Shift+Enter, the ROW/INDIRECT formula returns only the first character or an error.
  • Leaving the result as text. Extracted digits look like numbers but sort and calculate as text until you convert them with VALUE or *1.
  • Using INDIRECT on very long strings. INDIRECT is volatile and slow on large ranges; for thousands of rows, the helper-column method or Power Query is faster.
  • Assuming decimals or minus signs survive. The formula keeps digits only, so "-12.50" becomes "1250". Handle signs and decimal points separately if you need them.
  • Merged cells. Formulas fill down poorly across merged cells; unmerge first.

Tips

  • To keep digits and decimal points, replace the *1 test with a check that the character is a digit or a period.
  • To extract only the first group of digits, combine with FIND and MID rather than joining every digit in the cell.
  • Power Query (Data > Get Data) can split columns by non-digit characters and is easier to audit than a long formula.
  • Test on a copy of the sheet before filling down over live data.
  • Name your result column clearly, such as "Digits Only", so others know it is derived.

Troubleshooting

  • #NAME? error: TEXTJOIN is not available in your Excel version. Use the helper-column or VBA method.
  • Blank result: the cell may contain no digits, or the formula range is wrong. Check LEN(A2) returns the expected character count.
  • Only one digit returned: the formula was entered without array entry in Excel 2019 or earlier. Re-enter with Ctrl+Shift+Enter.
  • #VALUE! after conversion: the cell had no digits. Wrap in IFERROR.
  • Slow workbook: replace INDIRECT-based formulas with helper columns or Power Query, and avoid whole-column references.
  • Macro blocked: check Trust Center macro settings, and only enable macros from files you trust.

Frequently Asked Questions

Can Excel extract digits automatically without a formula?

Not with a single built-in command. Flash Fill (Ctrl+E) can sometimes learn the pattern after you type one or two examples, but it is unreliable with mixed text and should be checked row by row.

Does this work in Excel for Mac?

Yes. TEXTJOIN and the array formula work in current Excel for Mac. Use Cmd+Shift+Enter for array entry where needed.

How do I keep leading zeros?

Format the result column as Text before entering the formula, or prefix with an apostrophe. Converting to a number will drop leading zeros.

Can I extract digits from multiple cells at once?

Yes, fill the formula down. For a whole range in one cell, use TEXTJOIN over the range first, then apply the digit formula to that combined text.

Why does my formula return all characters, not just digits?

The numeric test is not working, usually because the cell contains spaces or non-breaking characters. Clean the text with TRIM or SUBSTITUTE first.

Is there a risk in using VBA?

Macros can run any action in your workbook, so only use code you trust and keep macro-enabled files separate from shared sheets.