Another challenging numbers extraction

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
4,527
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
This is a typical results for a table tennis league match that I’ve downloaded from the league and would like to do some analysis.


Excel 2013/2016
ABCD
1Home PlayerAway PlayerGamesScore
2AX7-1111-411-611-71-0
3AY11-811-611-61-0
4AZ11-711-86-117-1112-101-0
5BX9-1111-67-116-110-1
6BY11-911-811-91-0
7BZ8-1111-411-74-1110-120-1
8CX11-1311-76-119-110-1
9CY7-116-1111-313-119-110-1
10CZ8-115-1111-82-110-1
11ACXZ13-1511-48-1111-910-120-1
Sheet5


The results in Column-C are what I’m interested. The match is for best of 5 games (i.e. between 3-5 games) and each game to 11 points or 2 clear points if the score reached 10-10. E.g. the match between B & Z in Row 7 is 8-11, 11-4, 11-7, 4-11 and 10-12, Z won by 3-2.

The problem as you can see from the table is the score are all joined together with no spaces between them!
Any ideas as how to separate them would be much appreciated

From 7-1111-411-611-7 to 7-11 11-4 11-6 11-7 ?
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Few exceptions are there but check if it is useful:


A B C D
1 Home Player Away Player Games Score 1 5 9 13 17
2 A X 7-1111-411-611-7 1-0 =MID($D3,F$2,4) =MID($D3,G$2,4) =MID($D3,H$2,4) =MID($D3,I$2,4) =MID($D3,J$2,5)
3 A Y 11-811-611-6 1-0 =MID($D4,F$2,4) =MID($D4,G$2,4) =MID($D4,H$2,4) =MID($D4,I$2,4) =MID($D4,J$2,5)
4 A Z 11-711-86-117-1112-10 1-0 =MID($D5,F$2,4) =MID($D5,G$2,4) =MID($D5,H$2,4) =MID($D5,I$2,4) =MID($D5,J$2,5)
5 B X 9-1111-67-116-11 0-1 =MID($D6,F$2,4) =MID($D6,G$2,4) =MID($D6,H$2,4) =MID($D6,I$2,4) =MID($D6,J$2,5)
6 B Y 11-911-811-9 1-0 =MID($D7,F$2,4) =MID($D7,G$2,4) =MID($D7,H$2,4) =MID($D7,I$2,4) =MID($D7,J$2,5)
7 B Z 8-1111-411-74-1110-12 0-1 =MID($D8,F$2,4) =MID($D8,G$2,4) =MID($D8,H$2,4) =MID($D8,I$2,4) =MID($D8,J$2,5)
8 C X 11-1311-76-119-11 0-1 =MID($D9,F$2,4) =MID($D9,G$2,4) =MID($D9,H$2,4) =MID($D9,I$2,4) =MID($D9,J$2,5)
9 C Y 7-116-1111-313-119-11 0-1 =MID($D10,F$2,4) =MID($D10,G$2,4) =MID($D10,H$2,4) =MID($D10,I$2,4) =MID($D10,J$2,5)
10 C Z 8-115-1111-82-11 0-1 =MID($D11,F$2,4) =MID($D11,G$2,4) =MID($D11,H$2,4) =MID($D11,I$2,4) =MID($D11,J$2,5)
11 AC XZ 13-1511-48-1111-910-12 0-1 =MID($D12,F$2,4) =MID($D12,G$2,4) =MID($D12,H$2,4) =MID($D12,I$2,4) =MID($D12,J$2,5)
 
Upvote 0
thanks, didn't work.

the few exceptions are the problem, from your formula


Excel 2013/2016
ABCDEFGHI
1HomePlayer1591317
2AX7-1111-411-611-71-07-1111-411-611-7
3AY11-811-611-61-011-811-611-6
4AZ11-711-86-117-1112-101-011-711-86-117-1112-10
5BX9-1111-67-116-110-19-1111-67-116-11
6BY11-911-811-91-011-911-811-9
7BZ8-1111-411-74-1110-120-18-1111-411-74-1110-12
8CX11-1311-76-119-110-111-1311-76-119-11
9CY7-116-1111-313-119-110-17-116-1111-313-119-11
10CZ8-115-1111-82-110-18-115-1111-82-11
11ACXZ13-1511-48-1111-910-120-113-1511-48-1111-910-1
Sheet6
 
Last edited:
Upvote 0
I’ve downloaded from the league

Hi, are you sure there are no special non-printing characters that are between the scores?

You could check with =LEN(C2) to see if it matches the count of the visible characters.
 
Upvote 0
Place below code in module. It worked for me. Set no is 1 to 5.

e.g. =SetValue(D2,1) where D2 is cell address for Games D column and set no 1.

Code:
Public Function SetValue(Text As String, SetNo As Integer) As String
Dim a() As String
Dim s1 As String, s2 As String

a = Split(Text, "-")

SetValue = ""

Select Case SetNo
    Case 1
        s1 = a(0)
        Select Case Len(a(1))
            Case 4: s2 = Left(a(1), 2)
            Case 3: If Left(a(1), 2) > 20 Then s2 = Left(a(1), 1) Else s2 = Left(a(1), 2)
        End Select
    Case 2
         Select Case Len(a(1))
            Case 4: s1 = Right(a(1), 2)
            Case 3: If Left(a(1), 2) > 20 Then s1 = Right(a(1), 2) Else s1 = Right(a(1), 1)
            Case 2: s1 = Right(a(1), 1)
         End Select
        
         Select Case Len(a(2))
            Case 4: s2 = Left(a(2), 2)
            Case 3: If Left(a(2), 2) > 20 Then s2 = Left(a(2), 1) Else s2 = Left(a(2), 2)
            Case 2: s2 = Left(a(2), 1)
         End Select
    
    Case 3
        Select Case Len(a(2))
            Case 4: s1 = Right(a(2), 2)
            Case 3: If Left(a(2), 2) > 20 Then s1 = Right(a(2), 2) Else s1 = Right(a(2), 1)
            Case 2: s1 = Right(a(2), 1)
         End Select
        
         Select Case Len(a(3))
            Case 4: s2 = Left(a(3), 2)
            Case 3: If Left(a(3), 2) > 20 Then s2 = Left(a(3), 1) Else s2 = Left(a(3), 2)
            Case 2: If UBound(a) = 3 Then s2 = Right(a(3), 2) Else s2 = Left(a(3), 1)
            Case 1: s2 = a(3)
         End Select
    
    Case 4
        If UBound(a) < 4 Then GoTo Result
        
        Select Case Len(a(3))
            Case 4: s1 = Right(a(3), 2)
            Case 3: If Left(a(3), 2) > 20 Then s1 = Right(a(3), 2) Else s1 = Right(a(3), 1)
            Case 2: s1 = Right(a(3), 1)
         End Select
        
         Select Case Len(a(4))
            Case 4: s2 = Left(a(4), 2)
            Case 3: If Left(a(4), 2) > 20 Then s2 = Left(a(4), 1) Else s2 = Left(a(4), 2)
            Case 2: If UBound(a) = 4 Then s2 = Right(a(4), 2) Else s2 = Left(a(4), 1)
            Case 1: s2 = a(4)
         End Select
    
    Case 5
        If UBound(a) < 5 Then GoTo Result
        
        Select Case Len(a(4))
            Case 4: s1 = Right(a(4), 2)
            Case 3: If Left(a(4), 2) > 20 Then s1 = Right(a(4), 2) Else s1 = Right(a(4), 1)
            Case 2: s1 = Right(a(4), 1)
         End Select
        
         Select Case Len(a(5))
            Case 4: s2 = Left(a(5), 2)
            Case 3: If Left(a(5), 2) > 20 Then s2 = Left(a(5), 1) Else s2 = Left(a(5), 2)
            Case 2: If UBound(a) = 5 Then s2 = Right(a(5), 2) Else s2 = Left(a(5), 1)
            Case 1: s2 = a(5)
         End Select

End Select

Result:
SetValue = s1 & "-" & s2

End Function
 
Upvote 0
tested on a few results and it works

Great work, much appreciated.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,729
Members
449,049
Latest member
MiguekHeka

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