How to split text

Abdmujib

Board Regular
Joined
May 15, 2022
Messages
123
Office Version
  1. 2021
Platform
  1. Windows
Hello,

Please how can I split these strings with a common delimiter, the common Delimiter is "-", So I have difficulty in splitting it using Left, Right, Search functions because in some cases like B4 and B6 the delimiter appears twice leaving. so for case of B6 it will split it at the first "-" instead of the Second. Is there a way to go about it.

Note: the only thing that is common again is that there is are always three uppercase string before the "-". but my version does not support Regex.

Kindly help me out

1727195387167.png
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I deleted my original post when I realized it doesn't work. It actually WOULD work for B2, just not B6.
The issue with it isn't the two "-". That part is no problem. It is the capital letters in a row that causes my formulas not to work (where the first "-" it needs to look at HAS to be after the first set of three consecutive capital letters).
So my formula worked for all rows in your example except for row 6.
 
Upvote 0
Hi! As an option
Book1.xlsm
JKL
22TeamsHomeAway
23Delta1-F58-1Delta1F58
24Delta1-FDelta1F
25Delta1-F-389Delta1F
26Delta1-F-4-JDelta1F
Sheet3
Cell Formulas
RangeFormula
K23:K26K23=SUBSTITUTE(LEFT(MID("-"&SUBSTITUTE(J23:J26,"-",REPT("-",999)),1,999*2),999),"-","")
L23:L26L23=SUBSTITUTE(RIGHT(MID("-"&SUBSTITUTE(J23:J26,"-",REPT("-",999)),1,999*2),999),"-","")
Dynamic array formulas.
 
Upvote 1
I deleted my original post when I realized it doesn't work. It actually WOULD work for B2, just not B6.
The issue with it isn't the two "-". That part is no problem. It is the capital letters in a row that causes my formulas not to work (where the first "-" it needs to look at HAS to be after the first set of three consecutive capital letters).
So my formula worked for all rows in your example except for row 6
You're right. do you have a way you can work B6 out too
 
Upvote 0
Hi! As an option
Book1.xlsm
JKL
22TeamsHomeAway
23Delta1-F58-1Delta1F58
24Delta1-FDelta1F
25Delta1-F-389Delta1F
26Delta1-F-4-JDelta1F
Sheet3
Cell Formulas
RangeFormula
K23:K26K23=SUBSTITUTE(LEFT(MID("-"&SUBSTITUTE(J23:J26,"-",REPT("-",999)),1,999*2),999),"-","")
L23:L26L23=SUBSTITUTE(RIGHT(MID("-"&SUBSTITUTE(J23:J26,"-",REPT("-",999)),1,999*2),999),"-","")
Dynamic array formulas.
Thank You. it doesn't work. it has no way of differentiate home and away successfully.
 
Upvote 0
You're right. do you have a way you can work B6 out too
No, or else I would have posted it. Trying to write formulas that look at the case of characters in consecutive spaces is not my strong suit.
I believe it probably can be done, but is probably beyond my formula writing capabilities.
I could probably come up with a various "brute force" VBA solution, but it would be pretty ugly and inefficient.
 
Upvote 0
No, or else I would have posted it. Trying to write formulas that look at the case of characters in consecutive spaces is not my strong suit.
I believe it probably can be done, but is probably beyond my formula writing capabilities.
I could probably come up with a various "brute force" VBA solution, but it would be pretty ugly and inefficient.
REGEX would work but it's only on 365
 
Upvote 0
REGEX would work but it's only on 365
Yeah, there are a lot of good new functions, like TEXTSPLIT, that may also make things easier.

I am pretty sure you can use REGEX in VBA. So you should be able to write your own User Defined Function in VBA to do what you want.
I do not do much REGEX programming myself, so probably cannot offer any advice on that piece of it.
 
Upvote 0
Try

Book1
ABCDE
1
2TeamsHomeAway
3Anioly TorunAni-Bas BialystokBASAnioly TorunAniBas BialystokBAS
4Astra Nowa SoIAST-B-BialaBBBAstra Nowa SoIASTB-BialaBBB
5KS RudziniecRUD-Wks Czarni RadomWKSKS RudziniecRUDWks Czarni RadomWKS
6Avia-SwidnikAVI-McKis Energetyk JaworznoMCKAvia-SwidnikAVIMcKis Energetyk JaworznoMCK
7KS Lechia Tomaszow MazowieckiLEC-SiedlceSIEKS Lechia Tomaszow MazowieckiLECSiedlceSIE
8
9
10
Sheet3
Cell Formulas
RangeFormula
C3:C7C3=IFERROR(LEFT(B3,MAX(AGGREGATE(15,6,FIND(CHAR(ROW($65:$90))&"-",B3),1),AGGREGATE(15,6,FIND("-"&CHAR(ROW($65:$90)),B3),1)-1)),LEFT(B3,AGGREGATE(15,6,FIND("-"&CHAR(ROW($65:$90)),B3),1)-1))
D3:D7D3=IFERROR(MID(B3,MAX(AGGREGATE(15,6,FIND(CHAR(ROW($65:$90))&"-",B3),1),AGGREGATE(15,6,FIND("-"&CHAR(ROW($65:$90)),B3),1)-1)+2,99),MID(B3,AGGREGATE(15,6,FIND("-"&CHAR(ROW($63:$88)),B3),1)+1,99))
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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