Reduce string length by -1 delimiter at the time

psc1

New Member
Joined
Nov 27, 2011
Messages
32
Office Version
  1. 2010
Hello
Could one of you genius work that one out for me please :)
Trying to break down all strings length in a column by reducing the last value with its delimiter at each step .. all the way down to the last value
I tried to no avail and my head hurts :(

Book1
ABC
1
2Original strings
3a/b/c/d/e/f
4With formula
5a/b/c/d/e
6a/b/c/d
7a/b/c
8a/b
9a
101/2/3/4/5
11With formula
121/2/3/4
131/2/3
141/2
151
16
17
Sheet1
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This could be done without the helper cells that I have used but this way keeps the formulas a bit simpler. Is that any use to you?

21 03 25.xlsm
ABC
1
2
3a/b/c/d/e/f5
4a/b/c/d/e
5a/b/c/d
6a/b/c
7a/b
8a
9
101/2/3/4/54
111/2/3/4
121/2/3
131/2
141
Reduce by delimiter
Cell Formulas
RangeFormula
C3,C10C3=LEN(B3)-LEN(SUBSTITUTE(B3,"/",""))
B4:B8B4=LEFT(B$3,FIND("#",SUBSTITUTE(B3,"/","#",C$3-ROWS(B$4:B4)+1))-1)
B11:B14B11=LEFT(B$10,FIND("#",SUBSTITUTE(B10,"/","#",C$10-ROWS(B$11:B11)+1))-1)
 
Upvote 0
Here is one way to do it...
Excel Formula:
=LEFT(B3,FIND("\",SUBSTITUTE(B3,"/","\",LEN(B3)-LEN(SUBSTITUTE(B3,"/",""))))-1)
 
Upvote 0
Hi Peter,
This totally makes sense thanks :)
How would you apply this to the other strings in B column?
Must I copy/paste this formula for each string or can it be rolled out to the rest of B column?
Many thanks

Book2
ABCD
1
2
3a/b/c/d/e/f5
4a/b/c/d/e
5a/b/c/d
6a/b/c
7a/b
8a
9
101/2/3/4/54
111/2/3/4
121/2/3
131/2
141
15
16aa/bb/cc/dd
17a1/b1/c1/d1
181a1/1b1/1c1/1d1
19
20
Sheet1
Cell Formulas
RangeFormula
C3,C10C3=LEN(B3)-LEN(SUBSTITUTE(B3,"/",""))
B4:B8B4=LEFT(B$3,FIND("#",SUBSTITUTE(B3,"/","#",C$3-ROWS(B$4:B4)+1))-1)
B11:B14B11=LEFT(B$10,FIND("#",SUBSTITUTE(B10,"/","#",C$10-ROWS(B$11:B11)+1))-1)
 
Upvote 0
How would you apply this to the other strings in B column?
Must I copy/paste this formula for each string or can it be rolled out to the rest of B column?
Suggest that you try Rick's formula. It might be easier to apply to different sections in the column. :)
 
Upvote 0
Here is one way to do it...
Excel Formula:
=LEFT(B3,FIND("\",SUBSTITUTE(B3,"/","\",LEN(B3)-LEN(SUBSTITUTE(B3,"/",""))))-1)
Hello Rick
Thank you for your help :)
Tested your formula and it works for the last value (y)
How do I carry on the theme of removing last delimiter all the way to the last value (trying to avoid copy/paste for each results)?
Cheers
 
Upvote 0
I'm about to go to sleep for the night so I won't be able to follow up until tomorrow. However, I am not sure what your actual question is. Using an example of, say, three values... what does your data look like BEFORE any attempt is made to split it apart? What would that data look like after it has been split apart. What I am unclear on is how your existing data is laid out and exactly where the split apart values are to be placed.

Peter... if you are still following this thread and know what the OP is asking for, please feel free to jump in so the OP doesn't have to wait until I can get back here.
 
Upvote 0
If your original strings are scattered down column B and you want to avoid multiple copy/past, perhaps you could use another column for the results, like this where you just enter the first formula and copy down as far as you might need.

21 03 25.xlsm
ABC
1
2
3a/b/c/d/e/fa/b/c/d/e/f
4a/b/c/d/e
5a/b/c/d
6a/b/c
7a/b
8a
9 
101/2/3/4/51/2/3/4/5
111/2/3/4
121/2/3
131/2
141
15 
16 
17aa/bb/cc/ddaa/bb/cc/dd
18aa/bb/cc
19aa/bb
20aa
21 
Reduce by delimiter (2)
Cell Formulas
RangeFormula
C3:C21C3=IF(B3="",IFERROR(LEFT(C2,FIND("\",SUBSTITUTE(C2,"/","\",LEN(C2)-LEN(SUBSTITUTE(C2,"/",""))))-1),""),B3)
 
Upvote 0
I'm about to go to sleep for the night so I won't be able to follow up until tomorrow. However, I am not sure what your actual question is. Using an example of, say, three values... what does your data look like BEFORE any attempt is made to split it apart? What would that data look like after it has been split apart. What I am unclear on is how your existing data is laid out and exactly where the split apart values are to be placed.

Peter... if you are still following this thread and know what the OP is asking for, please feel free to jump in so the OP doesn't have to wait until I can get back here.
Thanks Rick for your time.
I will formulate in better terms what it is for and what is required then send an example :)
Have a good night ;)
 
Upvote 0

Forum statistics

Threads
1,216,117
Messages
6,128,935
Members
449,480
Latest member
yesitisasport

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