Return last numbers of a variable length string

maounde

New Member
Joined
Jan 8, 2008
Messages
22
I am at a loss here. I have a collection of urls like this:
http://mycompany.com/t5/something/bd-p/153 (I need the formula to return 153)
or
http://mycompany.com/t5/something-else/bd-p/52 (I need the formula to return 52 )

Problems I find:
- The length in characters of the urls are variable
- The numbers at the end could be 2 to 4 digits

The only reliable constant I have is that the number I need to extract at the end is always after the last "/" and there are always exactly 6 "/", if it helps.
thx in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Code:
=RIGHT(RIGHT(A1,5),LEN(RIGHT(A1,5))-FIND("/",RIGHT(A1,5)))

You said it's always AT MOST 4 digits. So just truncate that bad boy to 5 and then run your logic on that. Otherwise you could go through and start at the 6th "/" but that's a longer code.
 
Upvote 0
Wow... Both formulas work great. I am more familiar with the syntax of the first. The lookup one, with ^ and {}, not so much... but never mind, it works!
Thank you both!
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

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