RIGHT until "/"

Torstensson

New Member
Joined
May 27, 2011
Messages
6
Hi,

New here at the forum and looking for some help.

I have a couple of thousands strings that looks like this:
/art/telefon/mobiltelefon/varumrken/samsung/samsung-i9100galaxysii/150354.3211/

And this:
/art/dator/laptop/laptop-17-tum/packardbell-easynotelj71sb777nc/149524.3004/

What a want from this is the product name. As you can see it's not always the same amount of columns.

I was thinking of counting from the right to find the third "/" and extract to the second "/".

How is this done?

Thanks in advance!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
A bit messy but this should work (until someone posts a much better solution!)

=MID(SUBSTITUTE(SUBSTITUTE(A1,"/","~",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2),"/","#",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2),FIND("~",SUBSTITUTE(SUBSTITUTE(A1,"/","~",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2),"/","#",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2))+1,FIND("#",SUBSTITUTE(SUBSTITUTE(A1,"/","~",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2),"/","#",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2))-FIND("~",SUBSTITUTE(SUBSTITUTE(A1,"/","~",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2),"/","#",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))-2))-1)
 
Upvote 0
Perhaps
=TRIM(RIGHT(SUBSTITUTE(LEFT(SUBSTITUTE(A1, "/", REPT(" ",255), 3),255), "/", REPT(" ",255), 2), 255)
 
Upvote 0
A formula something inbetween mikerickson's and njimack's in rows 1:2, and how it's derived in rows 4:5, as well as a user-defined function in rows 7:8, this last supported by the code below.
Excel Workbook
ABCDE
1/art/telefon/mobiltelefon/varumrken/samsung/samsung-i9100galaxysii/150354.3211/samsung-i9100galaxysii
2/art/dator/laptop/laptop-17-tum/packardbell-easynotelj71sb777nc/149524.3004/packardbell-easynotelj71sb777nc
3
4/art/telefon/mobiltelefon/varumrken/samsung/samsung-i9100galaxysii/150354.3211/84467samsung-i9100galaxysii
5/art/dator/laptop/laptop-17-tum/packardbell-easynotelj71sb777nc/149524.3004/73264packardbell-easynotelj71sb777nc
6
7/art/telefon/mobiltelefon/varumrken/samsung/samsung-i9100galaxysii/150354.3211/samsung-i9100galaxysii
8/art/dator/laptop/laptop-17-tum/packardbell-easynotelj71sb777nc/149524.3004/packardbell-easynotelj71sb777nc
Sheet


Code:
Function SplitMe(StringToSplit, Delimiter, InstanceNoFromRight)
x = Split(StringToSplit, Delimiter)
SplitMe = x(UBound(x) - InstanceNoFromRight)
End Function
 
Upvote 0
A formula something inbetween mikerickson's and njimack's in rows 1:2, and how it's derived in rows 4:5, as well as a user-defined function in rows 7:8, this last supported by the code below.
<
Code:
Function SplitMe(StringToSplit, Delimiter, InstanceNoFromRight)
x = Split(StringToSplit, Delimiter)
SplitMe = x(UBound(x) - InstanceNoFromRight)
End Function

I really like that function - think I might have to save that to a module in my Personal.xls
 
Upvote 0

Forum statistics

Threads
1,224,513
Messages
6,179,214
Members
452,895
Latest member
BILLING GUY

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