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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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