Extracting number from a string of text in a particular cell

floored

New Member
Joined
Jun 26, 2002
Messages
16
I am working on cleaning up some data on an existing excel spreadsheet. In one column, there is a descriptive string of text which is followed by a "," and then a number identifying its category -- there are cases where there are multiple sets of data like this in one cell. I want to extract the first number.

Sample data

1)Dog Snacks/Treats , 244
2)Film/Film Processing, 132
3)Paper Towels, 222
4)Paper tablecloths , 221,Placemats ,223
5)Wine, 31

Desired Results

1) 244
2) 132
3) 222
4) 221
5) 31

I have attempted to nest the find formula (looking for the ,) inside Right and Left formulas, but for some reason I can't get it to select the numbers. For example when I use the formula right(A1,find(",",A1)) it returns "Snacks/Treats , 244".

I've considered exporting into a text file which I could open as a csv file to seperate these strings, but given the volumne of data I need to do this on, I'm concerned about maintaing the data's integrity.

Any thoughts on a formula which would extract this data?
 
Re: Extracting number from a string of text in a particular

floored said:
Dave,

The formula you provided was returning text rather than the numbers, but when I combined it with my original formula, it's now working about 95% of the time. Final solution that worked was:

=--WMID(right(a1,find(",",a1)),2,1,",")

Thanks everyone for your help.

Just curious: For which values did you get text? And, Care to post some examples from that 5% range?
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Re: Extracting number from a string of text in a particular

The formula that I suggested worked fine on the sample data and it gave a number result.
 
Upvote 0
Re: Extracting number from a string of text in a particular

The first example I gave in my initial post resulted in a return of "treats".

As to samples of the exceptions now....

Cold Remedies 532; Cough Remedies 534
Tea, Packaged & Bags , 315
Frozen Dinner Entrée , Full Cal , 483
Refrigerated Entrée, Meatless , 477


All errors which would be anticipated given the formula.
 
Upvote 0
Re: Extracting number from a string of text in a particular

This group of data is not consistent with your initial information.
 
Upvote 0
Re: Extracting number from a string of text in a particular

floored said:
The first example I gave in my initial post resulted in a return of "treats".

As to samples of the exceptions now....

Cold Remedies 532; Cough Remedies 534
Tea, Packaged & Bags , 315
Frozen Dinner Entrée , Full Cal , 483
Refrigerated Entrée, Meatless , 477


All errors which would be anticipated given the formula.

The shorter formula Dave suggested inexpensive. If you are willing to apply...

=IF(ISNUMBER(SETV(--WMID(A1,WORDCOUNT(A1,","),1,","),1)),GETV(1),IF(ISNUMBER(SETV(--WMID(A1,WORDCOUNT(A1),1),2)),GETV(2),#N/A))

you could catch some of the more difficult cases. Note that the entries like Cold Remedies 532; Cough Remedies 534 will result in the last number the string contains.
 
Upvote 0
Re: Extracting number from a string of text in a particular

Dave Patton said:
This group of data is not consistent with your initial information.

Exactly why it has returned the errors with the revised formula. -- I'm working with other people's sloppy data entry
 
Upvote 0
Re: Extracting number from a string of text in a particular

hope this work for you :

=VALUE(RIGHT(B2,5))
 
Upvote 0
Re: Extracting number from a string of text in a particular

hope this work for you!!

=VALUE(RIGHT(B2,5))
 
Upvote 0

Forum statistics

Threads
1,221,709
Messages
6,161,431
Members
451,705
Latest member
Priti_190

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