WallStreetMojo

WallStreetMojo

WallStreetMojo

MENUMENU
  • Blog
  • Free Video Tutorials
  • Courses
  • All in One Bundle
  • Login
Home » Excel, VBA & Power BI » Excel Tutorials » Extract Number from String Excel

Extract Number from String Excel

By Jeevan A YJeevan A Y | Reviewed By Dheeraj VaidyaDheeraj Vaidya, CFA, FRM

Extract Number from String in Excel

Splitting single-cell values into multiple cells, collating multiple cell values into one, is the part of data manipulation. With the help of the text function in excel “Left, MID, and Right,” we are able to extract part of the selected text value or string value. In order to make the formula dynamic, we can use other supporting functions like “Find and LEN.” However, the extraction of only numbers with the combination of alpha-numeric values requires an advanced level of formula knowledge. In this article, we will show you the 3 ways to extract numbers from a string in excel.

  • #1 – Extract Number from the String at the End of the String
  • #2 – Extract Numbers from Right Side but Without Special Characters
  • #3 – Extract Numbers from any Position of the String

Below we have explained the different ways of extracting the numbers from strings in excel. Read the entire article to know this technique.

Extract Number from String in Excel

#1 – How to Extract Number from the String at the End of the String?

When we get the data, it follows a certain pattern, and having all the numbers at the end of the string is one of the patterns.

You can download this Extract Number from String Excel Template here – Extract Number from String Excel Template

For example, the city with its pin code below is the sample of the same.

Extract Number from String Excel Example 1

In the above example, we have the city name and Zip code together. In this case, we know we have to extract Zip code from the right-hand side of the string. But one of the problems is we don’t know exactly how many digits we need from the right-hand side of the string.

One of the common things before the numerical value starts is the underscore (_) character. First, we need to identify the position of the underscore character. This can be done by using the FIND method. So apply the FIND function in excel.

Extract Number from String Excel Example 1-1

What is the text we need to find is the Find Text argument? In this example, we need to find the position of the underscore, so enter underscore in double-quotes.

Extract Number from String Excel Example 1-2

Within Text is in which text we need to find the mentioned text, so select cell reference.

Popular Course in this category
Sale
All in One Excel VBA Bundle (35 Courses with Projects)
4.9 (1,353 ratings)
35+ Courses | 120+ Hours | Full Lifetime Access | Certificate of Completion
View Course

Extract Number from String Excel Example 1-3

The last argument is not required, so leave it as of now.

Extract Number from String Excel Example 1-4

So, we have got positions of underscore character for each cell. Now we need to identify totally how many characters we have in the entire text. Apply the LEN function in excel to get the total length of the text value.

Extract Number from String Excel Example 1-5

Now we have total characters and positions of underscore before the numerical value. To supply the number of characters needed for the RIGHT function, we need to minus the Total Characters with Underscore Position.

Extract Number from String Excel Example 1-6

Now apply the RIGHT function in cell E2.

Extract Number from String Excel Example 1-7

So, like this, we can get the numbers from the right-hand side when we have a common letter before the number starts in the string value. Instead of having so many helper columns, we can apply the formula in a single cell itself.

Extract Number from String Excel Example 1-8

 =RIGHT(A2,LEN(A2)-FIND(“_”,A2))

This will eliminate all the supporting columns and reduce the time drastically.

#2 – Extract Numbers From Right Side but Without Special Characters

Assume we have the same data, but this time we don’t have any special character before the numerical value.

Example 2

In the previous example, we have found a special character position, but here we don’t have that luxury. So Below the formula below will find the numerical position.

Example 2-1

Don’t turn off your computer by looking at the formula; I will decode this for you.

For the SEARCH function in excel, we have supplied all the possible starting numbers of numbers, so the formula looks for the position of the numerical value. Since we have supplied all the possible numbers to the array, the resulting arrays also should contain the same numbers. Then MIN function in excel returns the smallest number among two, so the formula reads below.

=MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&”0123456789″))

So now we got a numerical position, now let’s find the total number of characters in the cell.

Example 2-2

This will return the total number of characters in the supplied cell value. Now LEN – Position of the Numerical value will return the number of characters required from the right side, so apply the formula to get the number of characters.

Example 2-3

Now apply the RIGHT function in excel to get only the numerical part from the string.

Example 2-4

To avoid multiple helper columns, let’s combine the formula in a single cell.

Example 2-5

=RIGHT(A2,LEN(A2)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&”0123456789″))+1)

#3 – Extract Number From Any Position in Excel

We have seen from the right side extraction, but this is not the case with all the scenarios, so now we will see how to extract numbers from any position of the string in excel.

Extract Number From Any Position 1

For this, we need to employ various functions of excel. Below is the formula to extract the numbers from any position of the string.

Extract Number From Any Position 1-1

=IF(SUM(LEN(A2)-LEN(SUBSTITUTE(A2, {“0″,”1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9”}, “”)))>0, SUMPRODUCT(MID(0&A2, LARGE(INDEX(ISNUMBER(–MID(A2,ROW(INDIRECT(“$1:$”&LEN(A2))),1))* ROW(INDIRECT(“$1:$”&LEN(A2))),0), ROW(INDIRECT(“$1:$”&LEN(A2))))+1,1) * 10^ROW(INDIRECT(“$1:$”&LEN(A2)))/10),””)

Recommended Articles

This has been a guide to Extract Number From String in Excel. Here we discuss the top 3 ways of extracting the numbers from strings in excel along with practical examples and a downloadable excel template. You may learn more about excel from the following articles –

  • MID Function in Excel
  • REPLACE Function in Excel
  • Substring in Excel
  • VBA String Functions
0 Shares
Share
Tweet
Share
All in One Excel VBA Bundle (35 Courses with Projects)
  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>
Primary Sidebar
Footer
COMPANY
About
Reviews
Contact
Privacy
Terms of Service
RESOURCES
Blog
Free Courses
Free Tutorials
Investment Banking Tutorials
Financial Modeling Tutorials
Excel Tutorials
Accounting Tutorials
Financial Statement Analysis
COURSES
All Courses
Financial Analyst All in One Course
Investment Banking Course
Financial Modeling Course
Private Equity Course
Venture Capital Course
Excel All in One Course

Copyright © 2021. CFA Institute Does Not Endorse, Promote, Or Warrant The Accuracy Or Quality Of WallStreetMojo. CFA® And Chartered Financial Analyst® Are Registered Trademarks Owned By CFA Institute.
Return to top

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

* Please provide your correct email id. Login details for this Free course will be emailed to you

Book Your One Instructor : One Learner Free Class
Let’s Get Started
Please select the batch
Saturday - Sunday 9 am IST to 5 pm IST
Saturday - Sunday 9 am IST to 5 pm IST

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

* Please provide your correct email id. Login details for this Free course will be emailed to you

Login

Forgot Password?

WallStreetMojo

Download Extract Number from String Excel Template

Special Offer - All in One Excel VBA Bundle (35 Courses with Projects) View More