How to extract number is a string of text?

wkirkcrawford

Board Regular
Joined
Dec 7, 2013
Messages
72
Greetings,

This is my string; LANTUS 24 Units in the Morning, 18 Units + HUMLOG at Dinner Time.

I need to extract the numbers, 24 and 18.

I've seen all kinds of answers, including VBA, which isn't for me.

W. Kirk Crawford
Tularosa, New Mexico
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
(a) are the numbers always 2-digits? (b) please update your profile to show what version of Excel you're running.
 
Upvote 0
BTW: do you want the numbers in 1 cell? What delimiter? Are there always only 2 numbers?
 
Upvote 0
Kweaver,

No, the number isn't always 2 digits.

Ver.#, Microsoft 365 MSO (16.0.13530.20054) 32-bit

W. Kirk Crawford
Tularosa, New Mexico
 
Upvote 0
Kweaver,

No, the number isn't always 2 digits.

Ver.#, Microsoft 365 MSO (16.0.13530.20054) 32-bit

W. Kirk Crawford
Tularosa, New Mexico
What result do you want in this example? It would help if you show a few examples with the desired results.
 
Upvote 0
Hi,

Assuming you want the numbers extracted to separate columns, and "Units" always immediately following the numbers, drag formula as far across columns as necessary.

Book3.xlsx
ABCDE
1LANTUS 24 Units in the Morning, 18 Units + HUMLOG at Dinner Time.2418  
2LANTUS 224 Units in the Morning, 18888 Units + HUMLOG at Dinner Time, 2 Units COOKIES before bed.224188882 
Sheet722
Cell Formulas
RangeFormula
B1:E2B1=IFERROR(RIGHT(SUBSTITUTE(TRIM(LEFT(SUBSTITUTE($A1,"Units",REPT(" ",255),COLUMNS($B1:B1)),255))," ",REPT(" ",255)),99)+0,"")
 
Upvote 0
In these kind of problems, it is usually best to show multiple examples, to try to capture all of the distinct structures and possibilities.
We need to see all the different ways this data might appear, and what your expected results look like.
 
Upvote 0
Hi,

Assuming you want the numbers extracted to separate columns, and "Units" always immediately following the numbers, drag formula as far across columns as necessary.

Book3.xlsx
ABCDE
1LANTUS 24 Units in the Morning, 18 Units + HUMLOG at Dinner Time.2418  
2LANTUS 224 Units in the Morning, 18888 Units + HUMLOG at Dinner Time, 2 Units COOKIES before bed.224188882 
Sheet722
Cell Formulas
RangeFormula
B1:E2B1=IFERROR(RIGHT(SUBSTITUTE(TRIM(LEFT(SUBSTITUTE($A1,"Units",REPT(" ",255),COLUMNS($B1:B1)),255))," ",REPT(" ",255)),99)+0,"")
Jtakw,

I couldn't get that to work.

Thanks.

W. Kirk Crawford
Tularosa, New Mexico
 
Upvote 0
As you can see, worked for me in my sample in Post #6.
Please explain How it didn't work for you....?
What's the Text string you're using, what cell it's in, and where are you extracting the numbers to...?
 
Upvote 0
As you can see, worked for me in my sample in Post #6.
Please explain How it didn't work for you....?
What's the Text string you're using, what cell it's in, and where are you extracting the numbers to...?
Jtakw,

You are using two other cells. I can't use that. Oh yes, I know, I could use it in some hidden cells, but I don't want that.

You also assumed I was going to put that info into other columns.

I just want to extract each number in different cells.

W. Kirk Crawford
Tularosa, New Mexico
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

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