# Find and Extract Number from String – Excel & Google Sheets

This tutorial will demonstrate you how to find and extract a number from inside a text string in Excel and Google Sheets. ## 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}.

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. ### 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: {8,#VALUE,#VALUE,#VALUE,#VALUE,#VALUE,#VALUE, #VALUE, #VALUE,7}.

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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.80911934,"math_prob":0.928066,"size":5472,"snap":"2021-43-2021-49","text_gpt3_token_len":1541,"char_repetition_ratio":0.1461229,"word_repetition_ratio":0.03354839,"special_character_ratio":0.30921054,"punctuation_ratio":0.2157936,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9846314,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],"im_url_duplicate_count":[null,2,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-21T05:04:09Z\",\"WARC-Record-ID\":\"<urn:uuid:918c542f-2b9e-4db6-90e4-9fb3001e983f>\",\"Content-Length\":\"107262\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:37a3d102-3669-4080-a59e-7d8c74d6ef13>\",\"WARC-Concurrent-To\":\"<urn:uuid:5b5b757a-32f4-4408-a500-5b387a9b5ac2>\",\"WARC-IP-Address\":\"172.66.40.136\",\"WARC-Target-URI\":\"https://www.automateexcel.com/formulas/find-extract-number-from-string/\",\"WARC-Payload-Digest\":\"sha1:IOIFCTCTV2TX2R2HBKKRJJWD5HXX56KX\",\"WARC-Block-Digest\":\"sha1:VEN2OKBXACBIOKCJCYT5RJMZSJ37ODLT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585381.88_warc_CC-MAIN-20211021040342-20211021070342-00545.warc.gz\"}"}