Extracting a number from a text string

smithgt

Board Regular
Joined
Jan 22, 2010
Messages
193
I'm looking fo use Excel to fix a problem with another application and how it sort numbers within a filename.

In Column A, I have the folowing rows of data. I'm looking to extract the number 98, 100 & 102 from each row. The problem I have is that whilst the start (left) position is always the same, the number length could be between two or five digits long.

CF\Subsidiary Rights Statement 98 from 400 to 403.pdf
CF\Subsidiary Rights Statement 100 from 406 to 409.pdf
CF\Subsidiary Rights Statement 102 from 412 to 415.pdf

How can I extact this number? (so I can use it to sort the filenames)

thanks
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I'm looking fo use Excel to fix a problem with another application and how it sort numbers within a filename.

In Column A, I have the folowing rows of data. I'm looking to extract the number 98, 100 & 102 from each row. The problem I have is that whilst the start (left) position is always the same, the number length could be between two or five digits long.



How can I extact this number? (so I can use it to sort the filenames)

thanks
Try this...

=LOOKUP(1E100,--MID(A2,32,{1,2,3,4,5}))
 
Upvote 0
Excellent.....Thank you :)

Is it possible to caculate the start position (currently 32) as the path may change in length, but the constant is "Subsidiary Rights Statement "
 
Upvote 0
Excellent.....Thank you :)

Is it possible to caculate the start position (currently 32) as the path may change in length, but the constant is "Subsidiary Rights Statement "
Try this...

xxxxx CF\Subsidiary Rights Statement 98 from 400 to 403.pdf
Some other stuff CF\Subsidiary Rights Statement 100 from 406 to 409.pdf
Subsidiary Rights Statement 102 from 412 to 415.pdf

=LOOKUP(1E100,--MID(A2,SEARCH("Subsidiary Rights Statement",A2)+28,{1,2,3,4,5}))

The 28 is 27 for the length of the string "Subsidiary Rights Statement" plus 1 for the space.
 
Upvote 0

Forum statistics

Threads
1,216,741
Messages
6,132,448
Members
449,728
Latest member
teodora bocarski

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