Extract names before and after a /

S.H.A.D.O.

Well-known Member
Joined
Sep 6, 2005
Messages
1,915
Good evening,

I am an avid darts fan and keep a spreadsheet of the different tornaments.
Now when the draw is shown on the Internet it is the format...

Code:
Rob Cross (3) v Steve Lennon/Rowby-John Rodriguez
John Henderson (14) v James Richardson/Jason Cullen
Mensur Suljovic (6) v Josh Payne/Jonny Clayton
Simon Whitlock (11) v Jan Dekker/Adrian Lewis
Joe Cullen (7) v Adam Huckvale/Jermaine Wattimena
Kim Huybrechts (10) v Wayne Jones/Jamie Lewis
Peter Wright (2) v Johan Engstrom/James Wilson
Gerwyn Price (15) v Toni Alcinas/Dragutin Horvat
Michael Smith (4) v Tobias Mueller/Stephen Bunting
Jelle Klaasen (13) v Ricky Evans/Krzysztof Ratajski
Daryl Gurney (5) v James Wade/Cristo Reyes
Mervyn King (12) v Ryan Joyce/Michael Rosenauer
Dave Chisnall (8) v Cameron Menzies/Kevin Munch
Ian White (9) v Christian Kist/Kyle Anderson
Michael van Gerwen (1) v Mike De Decker/Terry Jenkins
Darren Webster (16) v Jeffrey de Graaf/Steve Beaton

...for example.

What I want to be able to do is to split all the names into different columns please.

To split the name on the left I have come up with this formula:

Code:
=LEFT(A1,FIND(")",A1,1)*1)

To split the name to the right of the slash I have come up with this formula:

Code:
=MID(A1,FIND("/",A1)+1,9999)

But I can't seem to get it to do the name in the middle.

Any help will be greatly appreciated.

Thanks in advance.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Probably better ways, but how about
=MID(A1,FIND("v",A1,1)+2,FIND("/",A1,1)-FIND("v",A1,1)-2)
 
Upvote 0
=MID(A1,FIND("v",A1,1)+2,FIND("/",A1,1)-FIND("v",A1,1)-2)

Brilliant, thanks Fluff.

I just needed to add the space after the v.

Code:
MID(A1,FIND("v ",A1,1)+2,FIND("/",A1,1)-FIND("v ",A1,1)-2)

Thanks again and have a great weekend.
 
Upvote 0
Hi,

Try this single formula for extracting all 3 parts.
I'm not at my own computer and do not have the HTML maker on this computer, so I can only show the code.
Assuming your data starts at A1, place formula in B1 copied down as far as needed, and across to Column D.
I've also assumed you wanted to retain the number and brackets after the first set of name string (i.e. (3))

Code:
=TRIM(SUBSTITUTE(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1," v ","^"),"/","^")," ","/"),"^",REPT(" ",100)),COLUMNS($B:B)*100-99,100),"/"," "))
 
Upvote 0
I just needed to add the space after the v.
That would still fail if the first name was, say "Darren Pavlov" or "Gustav Medic"

Here is how I would do it.

Excel Workbook
ABCD
1Rob Cross (3) v Steve Lennon/Rowby-John RodriguezRob Cross (3)Steve LennonRowby-John Rodriguez
2John Henderson (14) v James Richardson/Jason CullenJohn Henderson (14)James RichardsonJason Cullen
3Mensur Suljovic (6) v Josh Payne/Jonny ClaytonMensur Suljovic (6)Josh PayneJonny Clayton
4Simon Whitlock (11) v Jan Dekker/Adrian LewisSimon Whitlock (11)Jan DekkerAdrian Lewis
5Joe Cullen (7) v Adam Huckvale/Jermaine WattimenaJoe Cullen (7)Adam HuckvaleJermaine Wattimena
6Kim Huybrechts (10) v Wayne Jones/Jamie LewisKim Huybrechts (10)Wayne JonesJamie Lewis
7Peter Wright (2) v Johan Engstrom/James WilsonPeter Wright (2)Johan EngstromJames Wilson
8Gerwyn Price (15) v Toni Alcinas/Dragutin HorvatGerwyn Price (15)Toni AlcinasDragutin Horvat
9Michael Smith (4) v Tobias Mueller/Stephen BuntingMichael Smith (4)Tobias MuellerStephen Bunting
10Jelle Klaasen (13) v Ricky Evans/Krzysztof RatajskiJelle Klaasen (13)Ricky EvansKrzysztof Ratajski
11Daryl Gurney (5) v James Wade/Cristo ReyesDaryl Gurney (5)James WadeCristo Reyes
12Mervyn King (12) v Ryan Joyce/Michael RosenauerMervyn King (12)Ryan JoyceMichael Rosenauer
13Dave Chisnall (8) v Cameron Menzies/Kevin MunchDave Chisnall (8)Cameron MenziesKevin Munch
14Ian White (9) v Christian Kist/Kyle AndersonIan White (9)Christian KistKyle Anderson
15Michael van Gerwen (1) v Mike De Decker/Terry JenkinsMichael van Gerwen (1)Mike De DeckerTerry Jenkins
16Darren Webster (16) v Jeffrey de Graaf/Steve BeatonDarren Webster (16)Jeffrey de GraafSteve Beaton
17Darren Pavlov (16) v Jeffrey de Graaf/Steve BeatonDarren Pavlov (16)Jeffrey de GraafSteve Beaton
18Gustav Medic (16) v Jeffrey de Graaf/Steve BeatonGustav Medic (16)Jeffrey de GraafSteve Beaton
Extract names
 
Last edited:
Upvote 0
Click on the Data tab above your ribbon

Click on the text to columns button in the Data Tools Section

Select Delimited

Enter "v" in the others option

Click ok

Repeat for /
 
Upvote 0
Select Delimited

Enter "v" in the others option

Click ok
I don't think that you have thought that through very well. :)
Why don't you give just your first step a try with the sample data provided?

Your idea of Text to Columns could be used for a fairly quick manual result though ..
- Do a Find/Replace on the column with Find what: " v " (without the quotes but with a space each side of the v), Replace with: / and make sure in Options that 'Match entire cell contents' is not checked.
- Text to Columns -> Delimited -> Other: / -> Finish
 
Last edited:
Upvote 0
Hi,

Try this single formula for extracting all 3 parts.
I'm not at my own computer and do not have the HTML maker on this computer, so I can only show the code.
Assuming your data starts at A1, place formula in B1 copied down as far as needed, and across to Column D.
I've also assumed you wanted to retain the number and brackets after the first set of name string (i.e. (3))

Code:
=TRIM(SUBSTITUTE(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1," v ","^"),"/","^")," ","/"),"^",REPT(" ",100)),COLUMNS($B:B)*100-99,100),"/"," "))
You appear to have a few superfluous substitutes going on in that formula. If a single formula, copied across and down, is desired then this considerably shorter one should do the same job:

=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1," v ","/"),"/",REPT(" ",100)),COLUMNS($B:B)*100-99,100))
 
Upvote 0
Variables name1, name2 and name3 hold the found names:
Code:
Sub FindNames()


    Dim name1$, name2$, name3$
    Dim re As Object 'RegExp
    Dim mc As Object 'MatchCollection
    Dim m As Object  'Match


    s = "Rob Cross (3) v Steve Lennon/Rowby-John Rodriguez"
    
    Set re = CreateObject("VBScript.RegExp")
    re.IgnoreCase = True
    re.Pattern = "(.+?)\s+\(\d+\)\s+v\s+(.+?)/(.+)"
    
    Set mc = re.Execute(s)
    If mc.Count > 0 Then
        Set m = mc(0)
        name1 = m.SubMatches(0)
        name2 = m.SubMatches(1)
        name3 = m.SubMatches(2)
    Else
        MsgBox "No match was found", vbExclamation
    End If


End Sub
 
Upvote 0
Variables name1, name2 and name3 hold the found names:
Code:
Sub FindNames()


    Dim name1$, name2$, name3$
    Dim re As Object 'RegExp
    Dim mc As Object 'MatchCollection
    Dim m As Object  'Match


    s = "Rob Cross (3) v Steve Lennon/Rowby-John Rodriguez"
    
    Set re = CreateObject("VBScript.RegExp")
    re.IgnoreCase = True
    re.Pattern = "(.+?)\s+\(\d+\)\s+v\s+(.+?)/(.+)"
    
    Set mc = re.Execute(s)
    If mc.Count > 0 Then
        Set m = mc(0)
        name1 = m.SubMatches(0)
        name2 = m.SubMatches(1)
        name3 = m.SubMatches(2)
    Else
        MsgBox "No match was found", vbExclamation
    End If
End Sub
First of all, I think the OP will end up having multiple cells in Column A to process, not just the one asked about. Secondly, I think the OP will want the split out values placed on the worksheet in adjacent columns. Given that, and assuming the OP is willing to use VBA code, I would propose this non-RegExp macro to do the job...
Code:
[table="width: 500"]
[tr]
	[td]Sub FindNames()
  With Columns("B")
    .Offset(, -1).Copy .Cells(1)
    .Replace " v ", "/", xlPart, , False, , False, False
    .TextToColumns , xlDelimited, , , False, False, False, False, True, "/"
  End With
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

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