KutoolsforOffice — One Suite. Five Tools. Get More Done.

How to extract numbers including decimals from text in Excel

AuthorAmanda LiLast modified

Numbers are often stored together with other text in Excel. A product list may contain values such as Weight: 25.75 kg, while an imported report may contain amounts such as Total: $1,250.50. When you need to calculate with those numbers, sorting through the text manually is not practical.

The best way to extract the number depends on the way your data is written. We’ll begin with a simple REGEXEXTRACT formula for whole numbers and decimals, then adjust it for values that contain thousands separators. You’ll also see alternatives for Excel versions without REGEXEXTRACT, including a character-by-character formula, Flash Fill, Power Query, and a formula for text with a predictable structure. Finally, we’ll use Kutools for Excel to extract numbers without writing a formula.


Extract whole numbers and decimal numbers with REGEXEXTRACT

Let’s begin with the simplest case. Each cell contains one number mixed with text. The number may be a whole number such as 36 or 1250, or it may contain decimal places such as 25.75 or 0.625.

Suppose the text you want to extract numbers from is stored in cells A2:A6:

Original textExpected result
Weight: 25.75 kg25.75
Price: $128.5128.5
Temperature: 36°C36
Length: 0.625 inches0.625
Quantity: 1250 units1250

If your Excel version supports REGEXEXTRACT, a short formula can pull the first number from each cell.

  1. Select cell B2 or another empty cell next to the first value.
  2. Enter the following formula:
    =--REGEXEXTRACT(A2,"\d+(?:\.\d+)?")
  3. Press Enter. Then drag the fill handle down to apply the formula to the remaining rows.
    Extract whole numbers and decimal numbers with REGEXEXTRACT in Excel

The pattern \d+ finds one or more digits. The optional (?:\.\d+)? part also includes a decimal point followed by digits when one is present. The double minus converts the extracted text into a number, so the result can be used directly in calculations.

📝 Notes:

  • REGEXEXTRACT is available in Microsoft 365.
  • REGEXEXTRACT returns the first matching number. If one cell contains two separate numbers, this formula does not combine or return both of them.

Extract numbers with thousands separators

The first formula works well until the numbers begin to contain commas. For example, extracting 1,250 with the previous formula would return only 1, because the comma is not included in the pattern.

For this situation, let’s use data that contains both thousands separators and decimal places:

Original textExpected result
Sales: $1,2501,250
Revenue: $12,450.7512,450.75
Visitors: 8,500 people8,500
Cost: $725.5725.5
Balance: $25,000.2525,000.25

Here we can expand the regular expression so Excel recognizes properly grouped commas as part of the number.

  1. Select an empty cell next to the first source value.
  2. Enter this formula:
    =NUMBERVALUE(REGEXEXTRACT(A2,"(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?"),".",",")
  3. Press Enter.
  4. Fill the formula down through the rest of the data.
    Extract numbers with thousands separators and decimals in Excel

The REGEXEXTRACT part now recognizes numbers such as 1,250 and 12,450.75. NUMBERVALUE then converts the extracted text into a real number while treating the period as the decimal separator and the comma as the group separator.

📝 Notes:

  • REGEXEXTRACT is available in Microsoft 365.
  • In the previous method, the extracted values contained only digits and a decimal point, so the double minus was enough to convert them into numbers. Here, NUMBERVALUE is used instead because it lets us explicitly tell Excel that the period is the decimal separator and the comma is the thousands separator.

Extract numbers when REGEXEXTRACT is unavailable

REGEXEXTRACT is convenient, but it is not available in every Excel installation. If you have LET, SEQUENCE, and CONCAT functions, you can build the number by checking the text one character at a time.

For this example, suppose A2:A6 contains:

Original textExpected result
Weight: 25.75 kg25.75
Invoice total $1,280.501,280.50
Distance: 36.8 miles36.8
Length: 0.625 inch0.625
Stock: 1250 units1250
  1. Select an empty cell next to the first value.
  2. Enter the following formula:
    =LET(
        characters,MID(A2,SEQUENCE(LEN(A2)),1),
        extracted,CONCAT(
            IF(
                ISNUMBER(--characters),
                characters,
                IF((characters=".")+(characters=","),characters,"")
            )
        ),
        NUMBERVALUE(extracted,".",",")
    )
  3. Press Enter.
  4. Copy the formula down to extract the number from the other cells.
    Extract numbers from text without REGEXEXTRACT in Excel

MID and SEQUENCE split the cell into individual characters. The IF function keeps digits, decimal points, and commas while discarding the other characters. CONCAT puts the retained characters back together, and NUMBERVALUE converts the result into a number.

📝 Notes:

  • This method works in Excel 2021 and later versions, as well as Microsoft 365.
  • This approach works best when each cell contains one number.
  • Because the formula keeps every period and comma it encounters, punctuation elsewhere in the text can affect the result.

Pull numbers from consistently formatted text with Flash Fill

Not every extraction needs a formula. When every row follows almost exactly the same pattern, showing Excel one or two examples may be enough.

For instance, suppose column A contains these weight descriptions:

Original textExpected result
Weight: 25.75 kg25.75
Weight: 18.5 kg18.5
Weight: 32 kg32
Weight: 44.25 kg44.25
Weight: 15 kg15
  1. In B2, type 25.75, then press Enter.
  2. Press Ctrl + E to fill the remaining cells with Flash Fill. 💡 Alternatively, go to the Home tab, click Fill in the Editing group, then choose Flash Fill.
    Pull decimal numbers from consistently formatted text with Flash Fill in Excel

Excel looks at the example you entered and fills the rest of the column using the same pattern.

📝 Note:

Flash Fill is best for a one-time cleanup. The results are ordinary values, not formulas, so they will not change automatically if you edit the original text later.


Extract numbers from large datasets with Power Query

Power Query is a good choice when you work with imported or regularly updated data, especially when the surrounding text is not always written in the same way. You can set up the extraction once, then reuse it whenever the data changes.

Suppose the Original text column contains values like these:

Original textExpected result
Order total: $2,450.752,450.75
Amount due 850 USD850
Invoice amount - $1,125.51,125.5
Paid: 320.25 dollars320.25
Balance remaining = $12,50012,500
  1. Click any cell in the source data.
  2. Go to Data > From Table/Range. If the data is not already formatted as a table, confirm the range when Excel prompts you.
    Load source data into Power Query in Excel
  3. In the Power Query Editor, click Add Column > Custom Column.
    Add a custom column in Power Query
  4. In the Custom Column dialog:
    1. Enter a name such as Extracted number.
    2. In the formula box, enter:
      Number.FromText(
          Text.Select([Original text], {"0".."9", ".", ","}),
          "en-US"
      )

      📝 Notes:

      • Replace [Original text] with the actual name of the column that contains your source text.
      • Text.Select keeps only the digits, periods, and commas. Number.FromText then converts the retained text into a number. The "en-US" argument tells Power Query to treat the comma as the thousands separator and the period as the decimal separator.
    3. Click OK.
      Enter a custom formula to extract numbers in Power Query
  5. Click Home > Close & Load to return the results to Excel.
    Close and load the Power Query results into Excel

The extracted numbers are returned in a new column:

Numbers extracted from text with Power Query in Excel

Because the extraction steps are saved in the query, you do not need to repeat them when the source data changes. After adding or updating data, right-click the loaded result table and choose Refresh to run the query again.

📝 Note:

This method assumes that each source cell contains only one number. If a cell contains several unrelated numbers, the formula may combine them, so you should isolate the required number first.


Extract a number when it appears between known text

Sometimes the structure of the text does most of the work for you. If every value starts and ends the same way, there is no need to search through every character.

Consider these entries:

Original textExpected result
Weight: 25.75 kg25.75
Weight: 18 kg18
Weight: 42.5 kg42.5
Weight: 7.25 kg7.25
Weight: 100 kg100

In every row, the number is located after Weight: and before kg. TEXTAFTER and TEXTBEFORE can use those two pieces of text as boundaries.

  1. Select an empty cell next to the first value.
  2. Enter:
    =--TEXTBEFORE(TEXTAFTER(A2,"Weight: ")," kg")
  3. Press Enter.
  4. Fill the formula down.
    Extract a decimal number between known text with TEXTAFTER and TEXTBEFORE in Excel

TEXTAFTER removes everything through Weight: . TEXTBEFORE then removes kg and everything after it. The double minus converts the remaining value into a number.

📝 Notes:

  • This method works in Excel 2024 and later versions, as well as Microsoft 365.
  • This method is very easy to read, but the surrounding text needs to be consistent. If some rows use a different label or unit, the formula may need to be adjusted.

Extract numbers from text in a few clicks with Kutools for Excel

If you do not want to build a formula, Kutools for Excel has an Extract Text tool with a ready-made option for extracting numbers. You select the cells, choose Extract the number, and check the results in the preview before applying them.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Integrated with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

For example, suppose cells A20:A24 contain:

Original textExpected result
Weight: 25.75 kg25.75
Price: $128.5128.5
Distance: 36.8 miles36.8
Length: 0.625 inches0.625
Quantity: 1250 units1250
  1. Select the cells that contain the numbers and text.
  2. Click Kutools > Text > Extract Text.
  3. In the Extract Text dialog, choose Extract the number. The pane on the right immediately shows the numbers that Kutools finds.
    Extract Text dialog of Kutools for Excel
  4. Click OK, then choose where you want to place the extracted results when prompted.
    Extract numbers including decimals from text with Kutools for Excel

The numbers are returned without having to create a helper formula or work out a regular expression. This can be particularly handy when you only need to clean a selected range and want to see the extracted values before committing the result.

Pros

  • Supports Microsoft 365 and Excel 2007 or later
  • No formula or regular expression to write
  • Works with both whole numbers and decimals
  • Shows the extracted results in a preview pane

Which method should you use?

There is no need to use the most complicated formula for every worksheet. Start by looking at how your text is structured, then choose the method that fits it.

SituationRecommended methodWhy
Each cell contains one whole number or decimalREGEXEXTRACTShort formula and easy to fill down
Numbers can contain commas such as 12,450.75REGEXEXTRACT + NUMBERVALUEHandles both grouped thousands and decimal places
REGEXEXTRACT is not availableLET formulaBuilds the number from individual characters
Every row follows the same visible patternFlash FillQuick for one-time extraction without formulas
You regularly import or refresh a large datasetPower QuerySaves the extraction as a repeatable transformation
The number always sits between the same textTEXTAFTER + TEXTBEFORESimple and easy to understand
You prefer a point-and-click approachKutools for ExcelExtracts numbers through a dialog without formulas

Frequently Asked Questions

Why does my extracted decimal appear rounded?

The underlying value may still contain the decimal places, but the result cell may be formatted to display only whole numbers. Increase the number of displayed decimal places or apply a suitable number format.

Why does REGEXEXTRACT return only part of a number with commas?

A basic pattern such as \d+(?:\.\d+)? does not include thousands separators, so a value such as 1,250 may be matched only up to the comma. Use a pattern that also recognizes grouped thousands.

What happens if a cell contains more than one number?

Some methods in this tutorial are designed for cells containing only one number. REGEXEXTRACT returns the first matching number, while formulas that keep every numeric character may combine multiple numbers together.

Why does the character-by-character formula sometimes return the wrong result?

The formula keeps all digits, periods, and commas in the cell. If the surrounding text contains other numbers or punctuation, those characters may also be included in the result.

Why does Flash Fill stop working correctly on some rows?

Flash Fill works best when the source text follows a consistent pattern. If the wording, spacing, or number position changes significantly between rows, Excel may not recognize the intended pattern.

Will Flash Fill update when the source text changes?

No. Flash Fill creates static values. If the original text changes, you need to run Flash Fill again.

Why does Power Query combine several numbers in one cell?

The Text.Select formula keeps every digit, period, and comma it finds. If a cell contains more than one separate number, those characters can be joined together. In that case, isolate the required part of the text before converting it.

How do I update the Power Query results after adding new data?

After updating the source table, right-click the loaded query result and choose Refresh.

What if TEXTAFTER or TEXTBEFORE is not available in my Excel?

These functions require Excel 2024 or later, or Microsoft 365. For older versions, use another formula, Flash Fill, Power Query, or Kutools for Excel.

Which method is better for data that changes frequently?

Use a formula when the source cells stay in the worksheet and you want results to update automatically. Power Query is better for larger datasets that are imported or refreshed regularly.

Which method is easiest for older Excel versions?

Kutools for Excel is a convenient option because it does not depend on newer worksheet functions and supports Microsoft 365 and Excel 2007 or later.


Conclusion

For a simple cell such as Weight: 25.75 kg, REGEXEXTRACT is usually the quickest formula because it can find both whole numbers and decimals with very little setup. When commas are part of the number, extending the regular expression and passing the result through NUMBERVALUE takes care of values such as 12,450.75.

That does not mean REGEXEXTRACT is the right choice for every worksheet. A character-based formula is useful when the newer regex functions are missing. Flash Fill is convenient for a quick cleanup, Power Query is better for data that comes back regularly, and TEXTAFTER with TEXTBEFORE is hard to beat when the text follows the same pattern in every row.

For a no-formula approach, Kutools for Excel lets you select Extract the number and preview the result directly in the Extract Text dialog, which makes it a straightforward option for extracting numbers from an existing range.

Once you know whether your data contains simple decimals, thousands separators, or a predictable text pattern, choosing the right extraction method becomes much easier.