ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Text
  3. Extract Numbers From Text in Excel

Extract Numbers From Text in Excel

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

To extract a number from text in Excel, cut it out with a text function and convert it with VALUE. For a number after a dash, use =VALUE(RIGHT(A2,LEN(A2)-FIND("-",A2))), or =VALUE(TEXTAFTER(A2,"-")) in Microsoft 365. Use LEFT for numbers at the start and MID for numbers in the middle. VALUE turns the result into a real number.

Key takeaways

  • Pick the function by position: LEFT for the start, RIGHT for the end, MID for the middle.
  • FIND locates a separator such as a dash or space, so the formula works for any length.
  • TEXTBEFORE and TEXTAFTER (Microsoft 365, Excel 2024) are the easiest way to split at a separator.
  • Text functions always return text. Wrap the result in VALUE to calculate with it.
  • For digits scattered anywhere in a cell, Microsoft 365 can join them with TEXTJOIN, MID and SEQUENCE.
On this page+
  1. Which formula should you use?
  2. How to extract a number at the start of text
  3. How to extract a number at the end of text
  4. How to extract a number with TEXTBEFORE and TEXTAFTER
  5. How to extract a number from the middle of text
  6. How to extract a number with a decimal point
  7. How to extract every digit from text
  8. Why you need VALUE at the end
  9. Practise it

To extract numbers from text in Excel, first decide where the number sits: at the start, at the end, after a separator, or scattered through the cell. Each position has its own text function, and you finish with VALUE so the result is a number you can add up. This guide covers each case with a formula that works on any length of text.

Which formula should you use?#

The right formula depends on where the number is and whether its length changes. Use this table to jump to the right section:

Text in A2Number you wantFormulaResult
250kgAt the start=VALUE(LEFT(A2,LEN(A2)-2))250
INV-2048After a dash=VALUE(RIGHT(A2,LEN(A2)-FIND("-",A2)))2048
INV-2048After a dash (Microsoft 365)=VALUE(TEXTAFTER(A2,"-"))2048
Box 12 of 40In the middle=VALUE(MID(A2,5,2))12
Ref A7-B3-9Every digit=--TEXTJOIN("",TRUE,IFERROR(--MID(A2,SEQUENCE(LEN(A2)),1),""))739

Every formula ends in a real number, not text, thanks to VALUE or --. The sections below explain each one.

How to extract a number at the start of text#

Use LEFT when the number comes first. For a weight like "250kg", the unit is always two characters, so keep everything except the last two:

Excel formula
=VALUE(LEFT(A2,LEN(A2)-2))

LEN counts the characters (5), minus 2 leaves 3, and LEFT takes the first 3: "250". VALUE turns it into 250. This works for "75kg" and "1200kg" too, because the formula never assumes the number's length.

If the number ends at a space, as in "42 units", find the space instead: =VALUE(LEFT(A2,FIND(" ",A2)-1)) returns 42.

How to extract a number at the end of text#

Use RIGHT when the number comes last. For invoice codes like "INV-2048", FIND gives the position of the dash, and everything after it is the number:

Excel formula
=VALUE(RIGHT(A2,LEN(A2)-FIND("-",A2)))

The dash is character 4 and the text has 8 characters, so RIGHT takes the last 4: "2048". VALUE returns 2048. The same formula gives 731 for "INV-731" and 15002 for "INV-15002". The lesson on LEFT, RIGHT, MID and LEN practises exactly this kind of split.

How to extract a number with TEXTBEFORE and TEXTAFTER#

In Microsoft 365 and Excel 2024, TEXTAFTER returns everything after a separator, so you don't need to count characters:

Excel formula
=VALUE(TEXTAFTER(A2,"-"))

For "INV-2048" the result is 2048. TEXTBEFORE does the opposite. Combine them to pull a number out from between two separators. For "Order 5531 shipped":

Excel formula
=VALUE(TEXTBEFORE(TEXTAFTER(A2," ")," "))

TEXTAFTER returns "5531 shipped", and TEXTBEFORE keeps the part before the next space: 5531. More examples are in how to extract text between two characters, and the same idea pulls the domain out of an email address.

How to extract a number from the middle of text#

MID takes characters from any position: MID(text, start, how many). For "Box 12 of 40", the number starts at character 5 and is 2 long:

Excel formula
=VALUE(MID(A2,5,2))

The result is 12. When the position changes from row to row, calculate it with FIND. The number starts after the first space and ends before " of":

Excel formula
=VALUE(MID(A2,FIND(" ",A2)+1,FIND(" of",A2)-FIND(" ",A2)-1))

This also returns 12, and it works for "Box 7 of 40" or "Box 125 of 400". The MID function guide explains the three arguments.

How to extract a number with a decimal point#

Split at the characters around the number, not at the digits, and the decimal point comes along. For "Price: 12.50 USD", the number sits between ": " and the next space:

Excel formula
=VALUE(TEXTBEFORE(TEXTAFTER(A2,": ")," "))

TEXTAFTER returns "12.50 USD", TEXTBEFORE keeps "12.50", and VALUE returns 12.5. Format the cell with two decimals if you want to see 12.50. In older versions, the MID and FIND pattern from the previous section does the same job. If VALUE returns #VALUE! here, your computer may use a comma as the decimal separator, so check the regional settings.

How to extract every digit from text#

When digits are scattered through the text, Microsoft 365 can test each character and keep only the digits:

Excel formula
=--TEXTJOIN("",TRUE,IFERROR(--MID(A2,SEQUENCE(LEN(A2)),1),""))

For "Ref A7-B3-9" the result is 739. Here is how it works:

  1. SEQUENCE(LEN(A2)) makes the list 1, 2, 3 and so on, one number per character.
  2. MID(A2, ..., 1) splits the text into single characters.
  3. -- turns digits into numbers; letters, spaces and dashes become errors.
  4. IFERROR swaps the errors for empty text, and TEXTJOIN glues the digits together.
  5. The -- at the front turns "739" into the number 739.

This joins every digit, so it drops decimal points and minus signs, and it can't separate two numbers in one cell. Recent Microsoft 365 builds also include REGEXEXTRACT, which can return the first run of digits with =--REGEXEXTRACT(A2,"\d+"). Older versions need Flash Fill: type the first answer, then press Ctrl+E on Windows, or use Data > Flash Fill on a Mac.

Why you need VALUE at the end#

Text functions always return text, even when the result looks like a number. Without VALUE, "2048" sits on the left of the cell, SUM ignores it, and a lookup against the number 2048 fails. The VALUE function guide covers the details, and -- in front of a formula does the same job.

Keep the result as text when the digits are an ID with leading zeros, such as "00731". VALUE would turn it into 731. For more on text that looks like numbers, see numbers stored as text.

Practise it#

Splitting codes and IDs is one of the most common data-cleaning jobs in a real sheet. Practise LEFT, RIGHT, MID and LEN in a live spreadsheet: you split real product codes and the lesson checks each formula instantly. Then practise TEXTBEFORE and TEXTAFTER to split text at a separator in one step.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Get the invoice number from A2 as a real number. In B2, use FIND to locate the dash, RIGHT to take everything after it, and VALUE to convert it.

fx
ABCD
1
Invoice
Number
2
INV-2048
3
INV-731
4
INV-15002
5
6
7

Tip: LEN(A2)-FIND("-",A2) is how many characters come after the dash.

Practise this in a lesson

LessonLEFT, RIGHT, MID and LENSplit product codes and IDs into their parts by taking characters from the start, end or middle of the text.LessonTEXTBEFORE and TEXTAFTERSplit emails, "Last, First" names and file paths at a delimiter with TEXTBEFORE and TEXTAFTER, including picking which occurrence to split at.Function guideMIDPull characters from any position with Excel's MID. Extract IDs, email domains and text between brackets with FIND. Examples and live practice.Function guideVALUEFix numbers stored as text with Excel's VALUE function, so SUM and lookups work again. Examples, common mistakes and a live practice exercise.

Frequently asked questions

How do I extract only numbers from a cell in Excel?

+

If the number sits in a fixed place, use LEFT, RIGHT or MID with VALUE. If digits are mixed in anywhere, Microsoft 365 users can use =--TEXTJOIN("",TRUE,IFERROR(--MID(A2,SEQUENCE(LEN(A2)),1),"")), which keeps every digit and drops everything else.

Why can't I add up the numbers I extracted?

+

LEFT, RIGHT, MID and TEXTAFTER return text, even when it looks like a number, and SUM ignores text. Wrap the formula in VALUE, or put -- in front, to turn the result into a real number.

How do I get the number after a dash in Excel?

+

Use =VALUE(TEXTAFTER(A2,"-")) in Microsoft 365 or Excel 2024. In older versions, use =VALUE(RIGHT(A2,LEN(A2)-FIND("-",A2))), which takes every character after the dash.

Can Flash Fill extract numbers from text?

+

Yes. Type the number for the first row, then press Ctrl+E on Windows or use Data > Flash Fill. Flash Fill copies the pattern down, but the results don't update if the source text changes.

Sources

  • MID, MIDB functions - Microsoft Support
  • VALUE function - Microsoft Support
  • TEXTAFTER function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Which formula should you use?
  2. How to extract a number at the start of text
  3. How to extract a number at the end of text
  4. How to extract a number with TEXTBEFORE and TEXTAFTER
  5. How to extract a number from the middle of text
  6. How to extract a number with a decimal point
  7. How to extract every digit from text
  8. Why you need VALUE at the end
  9. Practise it

Keep reading

Text· 7 min read

Extract the Domain or Username From an Email in Excel

To extract the domain from an email address, take everything after the @ sign. In Microsoft 365, use =TEXTAFTER(A2,"@"). In any version, use =MID(A2,FIND("@",A2)+1,LEN(A2)). For the username, take everything before the @: =TEXTBEFORE(A2,"@") or =LEFT(A2,FIND("@",A2)-1). Wrap either in IFERROR for cells without an @.

Text· 6 min read

Extract Text Between Two Characters in Excel

To extract text between two characters in Microsoft 365, nest TEXTAFTER inside TEXTBEFORE: =TEXTBEFORE(TEXTAFTER(A2,"("),")") returns what sits between the brackets. In any version, use MID and FIND: =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1). FIND gives the positions of the two characters, and MID takes the text between them.

Text· 7 min read

Get Initials From a Name in Excel

To get initials from a name in Excel, take the first letter of the first name and the first letter after the space: =LEFT(A2,1)&MID(A2,FIND(" ",A2)+1,1) turns Maria Lopez into ML. In Microsoft 365 or Excel 2024, =CONCAT(LEFT(TEXTSPLIT(A2," "))) returns the initials of every word, including middle names.

More on text

  • Find the Nth Occurrence of a Character in Excel
  • Find the Position of Text in a Cell (FIND and SEARCH)
  • How to Format Phone Numbers in Excel
  • How to Add or Keep Leading Zeros in Excel
  • LEFT, RIGHT and MID in Excel: Pull Out Part of a Cell
  • Line Breaks in Excel: In a Cell and in a Formula
All text articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free