Extract a Numeric string from an alphanumeric string

daniqwerty987

New Member
Joined
Aug 16, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I am new in the forum. I am struggling in extracting a 5 digit code from an alphanumeric string. I tried in different ways but it is not working. The format I would like to extract is for example "14.508" and an example of the string could be "aa7fr0V14.508bgt9".

Thanks a lot if you can help me!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If it is at the exact place always you can use MID, else a regex would be better. Not very proficient with excel functions, maybe there is a good one for this case.
 
Upvote 0
It would be helpful if you provided several representative examples of your data.
 
Upvote 0
This will work for a very specific data structure. Must have a six character number (five digits and a decimal) that starts on or before the 50th character in the string. You can see it fails for other data structures. The last example use $500 instead of $50 if the occurrence is late in a long string.

Book1
AB
1aa7fr0V14.508bgt914.508
2aa7fr0V14508bgt99
3aa7fr0V-14.508bgt9-14.50
4aa7fr0V+14.508bgt9+14.50
5aa7fr0V(1456)bgt9(1456)
6aa7fr0V+bgtaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa14.508bbbbbb#N/A
7aa7fr0V+bgtaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa14.508bbbbbb14.508
Sheet1
Cell Formulas
RangeFormula
B1:B5B1=MID(A1,MATCH(TRUE,ISNUMBER(--MID(A1,ROW($1:$50),6)),0),6)
B6B6=MID(A6,MATCH(TRUE,ISNUMBER(--MID(A6,ROW($1:$50),6)),0),6)
B7B7=MID(A7,MATCH(TRUE,ISNUMBER(--MID(A7,ROW($1:$500),6)),0),6)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
I'm with kweaver... post several representative examples. What we cannot tell for sure from your single example... Is there always a decimal point? If so, is the decimal point always between the 2nd and 3rd digits? And, if so, is the number you want always to only number with a decimal point in it? Could there ever be a period (which is basically a decimal point between non-digits) in the text? Also, is a VBA solution acceptable?
 
Upvote 0

Forum statistics

Threads
1,215,943
Messages
6,127,826
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top