Find and Extract Number from String – Excel & Google Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on August 19, 2023
Download Example Workbook

Download the example workbook

This tutorial will demonstrate you how to find and extract a number from inside a text string in Excel and Google Sheets.

find extract number from string Main Funct...

Find and Extract Number from String

Sometimes your data may contain numbers and text and you want to extract the numerical data.

If the number part is on the right or left side of the string, it’s relatively easy to split the number and text . However, if the numbers are inside the string, i.e. between two text strings, you will need to use a much more complicated formula (shown below).

TEXTJOIN – Extract Numbers in Excel 2016+

In Excel 2016 the TEXTJOIN function was introduced, which can extract the numbers from anywhere of the text string. Here is the formula:



Let’s see how this formula works.

The ROW, INDIRECT and LEN Functions returns an array of numbers corresponding to each character in your alphanumerical string. In our case, “Monday01Day” has 11 characters, so the ROW function will then return the array {1;2;3;4;5;6;7;8;9;10;11}.

=TEXTJOIN("",TRUE,IFERROR((MID(B3, {1;2;3;4;5;6;7;8;9;10;11},1)*1),""))

Next, the MID Function extracts each character from the text string, creating an array containing your original string:


Multiplying each value in the array by 1 will create an array containing errors If the array character was text:


Next, the IFERROR Function, removes the error values:


Leaving only the TEXTJOIN Function which joins the remaining numbers together.

Note that the formula will give you all the numeric characters together from your string. For example, if your alphanumerical string is Monday01Day01, it will give you 0101 as a result.
TextJoin 01

Extract Numbers – Before Excel 2016

Before Excel 2016, you could use a much more complicated method to extract numbers from text. You can use the FIND function together with the IFERROR and MIN functions to determine both the first position of the number part and the first position of the text part after the number. Then we simply extract the number part with the MID function.



Note: This is an Array formula, you must enter the formula by pressing CTRL + SHIFT + ENTER, instead of just ENTER.

Let’s see step by step how this formula works.

Find Fist Number

We can use the FIND function to locate the starting position of the number.



For the find_text argument of the FIND function, we use the array constant {0,1,2,3,4,5,6,7,8,9}, which makes the FIND function to perform a separate search for each value in the array constant.

The within_text argument of the FIND function in our case is Monday01Day, in which 1 can be found at the position 8, and 0 at the position 7, so our result array will be: {7,8,#VALUE,#VALUE,#VALUE,#VALUE,#VALUE,#VALUE, #VALUE,#VALUE}.

Using the IFERROR function we replace the #VALUE errors by 999999999. Then we simply look for the minimum within this array and get therefore the place of the first number (7).

Please note that the above formula is an array formula, you have to press Ctrl+Shift+Enter to trigger it.

Find First Text Character After Number

Similarly to locating the first number within the string, we use the FIND function to determine where the text begins again after the number making good use also of the start_num argument of the function.



This formula works very similarly to the previous one used for locating the first number, only we use letters in our array constant and therefore numbers cause #VALUE errors. Please note that we start searching only after the position determined for the first number (this will be the start_num argument) and not from the beginning of the string.

Don’t forget to press Ctrl+Shift+Enter to use of the above formula.

There is nothing left than putting this all together.

Extract Number From Two Texts

Once we have the starting position of the number part and the beginning of the text part after that, we simply use the MID function to extract the desired number part.



Other Method

Without explaining it in more detail, you can also use the below complex formula to get the number from inside a string.



Please be aware that this formula above will give you 0 when there is no number found in the string and that leading zeros will be left out.


Find and Extract Number from String to Text in Google Sheets

The examples shown above work the same way in Google Sheets as they do in Excel.

find extract number from string Google Function

AI Formula Generator

Try for Free

Excel Practice Worksheet

practice excel worksheet

Practice Excel functions and formulas with our 100% free practice worksheets!

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!

Free Download

Return to Excel Formulas List