Split data in cells

Davebro

Board Regular
Joined
Feb 22, 2018
Messages
150
Office Version
  1. 365
  2. 2021
  3. 2016
Platform
  1. Windows
First column to be separated if possible
Champions LeagueBayern MunichCeltic3:1Champions LeagueBayernCeltic3:1
Champions LeagueAtalantaClub Brugge2:1Champions LeagueAtalantaClubBrugge2:1
England - League OneWycombeBristol Rovers2:0England League OneWycombeBristol Rovers2:0
England - ChampionshipPreston North EndMillwall2:1England ChampionshipPreston North EndMillwall2:1
 
Because competitions and teams can be...basically anything, and even the nation prefix (England, Spain, Germany, etc) is fairly fixed but could be a long list, you really need a delimiter between the sections of data.

If that isn't possible, you'll really need a hefty list to tell the workbook what to look for. Something like

=left([cell], 5)
Then do a quick match/lookup to see if those first 5 characters are "Champ" or "Europ" or "Engla" or "Germa", and from there, you could code to (1) deduce what that first intro value is and how long that entry should be, then you determine when the next entry will start.

However, you quickly get into the issue of identifying the clubs themselves. If you're talking about just the first 4 tiers of the Big Five (England, Spain, Germany, France, Italy), that would be some 450ish teams. But because we have Champions League, you'd also need to include the entire First Tier of basically every club in UEFA, and probably the 2nd tier & 3rd tier if you'd like it to work for several years. That list would get VERY long, indeed.

Is there another source of the match results that does include delimiters?
 
Upvote 0
Do you have the new REGEXEXTRACT function in your 365 version?
If so, you could see if this is any use.
(BTW, shouldn't it be "Club Brugge" as below rather than "AtlantaClub" as in your sample?)

Davebro.xlsm
ABCDE
1Champions LeagueBayern MunichCeltic3:1Champions LeagueBayern MunichCeltic3:1
2Champions LeagueAtalantaClub Brugge2:1Champions LeagueAtalantaClub Brugge2:1
3England - League OneWycombeBristol Rovers2:0England - League OneWycombeBristol Rovers2:0
4England - ChampionshipPreston North EndMillwall2:1England - ChampionshipPreston North EndMillwall2:1
Split Text
Cell Formulas
RangeFormula
B1:B4B1=REGEXEXTRACT(A1,".+?[a-z](?=[A-Z])")
C1:C4C1=SUBSTITUTE(REGEXEXTRACT(A1,".+[a-z](?=[A-Z])"),B1,"")
D1:D4D1=SUBSTITUTE(REGEXEXTRACT(A1,".+?(?=\d)"),B1&C1,"")
E1:E4E1=REGEXEXTRACT(A1,"[0-9:]+$")
 
Upvote 0
Solution
Do you have the new REGEXEXTRACT function in your 365 version?
If not, or you want/need to use other Excel versions, you could see if this user-defined function (UDF) does what you need. To implement ..

1. Right click the sheet name tab and choose "View Code".
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below (you can use the icon at the top right of the code pane below) into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Enter the formula as shown in B1 in the screen shot below and copy down.
6. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

N.B. With this UDF and the formula suggestion above, your actual data may have more variations which might mean tweaks to either formulas or code (or it may prove that these approaches are not robust enough for your data)

VBA Code:
Function SplitIt(s As String) As Variant
  Dim RX As Object, M As Object
  Dim a(1 To 4)
 
  Set RX = CreateObject("VBScript.RegExp")
  RX.Global = True
  RX.Pattern = "[A-Z].+?\w(?=[A-Z]|\d)"
  Set M = RX.Execute(s)
  a(1) = M.Item(0)
  a(2) = M.Item(1)
  a(3) = M.Item(2)
  a(4) = Mid(s, Len(a(1) & a(2) & a(3)) + 1)
  SplitIt = a
End Function

Davebro.xlsm
ABCDE
1Champions LeagueBayern MunichCeltic3:1Champions LeagueBayern MunichCeltic3:1
2Champions LeagueAtalantaClub Brugge2:1Champions LeagueAtalantaClub Brugge2:1
3England - League OneWycombeBristol Rovers2:0England - League OneWycombeBristol Rovers2:0
4England - ChampionshipPreston North EndMillwall2:1England - ChampionshipPreston North EndMillwall2:1
Split Text (2)
Cell Formulas
RangeFormula
B1:E4B1=SplitIt(A1)
Dynamic array formulas.
 
Upvote 0
WOW, thank you so much for this, it has save me a lot of time splitting these up. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,226,837
Messages
6,193,253
Members
453,784
Latest member
Chandni

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