Extracting numbers from long text strings

DanQuinn

New Member
Joined
Mar 17, 2011
Messages
2
I have a column full of data (dumped from a source where I have no control) where the text is presented as follows...

Random Word Date Random Text 2.245% Random Ending

The length of the text is not consistent.
The position of the number is not consistent.
The number of decimal places of the % value is not consistent.
The % value is what I want but there may be other numbers in there as well (as part of date descriptors, etc.) - but at least there's only one percentage.
Not all the lines have percentages (need to produce blank instead of error).

1. Is there a way of extracting out just the % value (with or without the % sign, doesn't matter) and leaving it formatted as a number instead of text?

2. I know I can create a simple follow-me macro where I enter the cell, go into edit mode, search for a %, hit ctrl-left to get back to the previous space, marquee select to the following space, copy, right-cell, paste...but hoping for a more elegant solution.

Thanks for your help all!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,

Try this in B1

=TRIM(MID(SUBSTITUTE(" "&A1," ",REPT(" ",100)),SEARCH("%",SUBSTITUTE(" "&A1," ",REPT(" ",100)))-50,100))

HTH

M.
 
Upvote 0
Try,

=TRIM(RIGHT(LEFT(SUBSTITUTE(A1&" 0%"," ",REPT(" ",100)),FIND("%",SUBSTITUTE(A1&" 0%"," ",REPT(" ",100)))),100))+0
 
Upvote 0
Thanks all! Worked perfectly!

Now if only I could sort out the garbage of the date in the same field...(sometimes in one format, sometimes in another, spaces here and there...total garbage).
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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