Formula help - Pulling 3rd & 4th number from string but blank if no 3rd & 4th number

jack109

Board Regular
Joined
May 10, 2020
Messages
76
Office Version
  1. 365
Platform
  1. Windows
Hi

Im extracting the times of 1st and 2nd goals from times that are a text string. The first formula works fine but the second works unless there is no second goal or if both goals are scored with single digit numbers or single and double digits. Is there a way to amend the formula so that if there is no second goal? The last two rows are an example of when there single and double digit goals causing an issue too.

Any help would be grateful

GOALTIMES.xlsm
ABCDE
1
2TIMESFIRSTSECOND
323 832383
417 451745
533 43 683368
6909090
7777777
810 611061
958 765876
10454545
1131 523152
12797979
1300
14161616
15141414
1648 904890
1724 492449
18262626
193 9339
2052655
Sheet1
Cell Formulas
RangeFormula
D3:D20D3=NUMBERVALUE(LEFT(B3,2))
E3:E20E3=NUMBERVALUE(IF(ISNUMBER(VALUE(RIGHT(B3,4))),RIGHT(B3,4),RIGHT(B3,3)))
 
Would this be any use?

25 02 27.xlsm
BCDE
1
2TIMESFIRSTSECOND
323 832383
417 451745
533 43 683343
69090
77777
810 611061
958 765876
104545
1131 523152
127979
13 
141616
151414
1648 904890
1724 492449
182626
193 939
2055
Goals
Cell Formulas
RangeFormula
D3:E20D3=LET(a,TAKE(TEXTSPLIT(B3&" "," "),,2),IFERROR(--a,a))
Dynamic array formulas.
 
Upvote 0
sorry to be a pain but is there a way that this can be done using two formulas instead? Im encountering a problem not with the formula but how Im trying to get use the data
 
Upvote 0
Here is more data which will show what I'm trying to achieve. Basically I want to know who scored the first and second goals, I have no problem achieving that with the first but its when Im trying to determine who scored the second goal if any. The second goal columns I & J have been entered manually to show my expected result.

Maybe the formula I've marked as the solution is the answer, maybe I looking at using it in the wrong way?

Any help would once again be greatly appreciated.

GOALTIMES.xlsm
ABCDEFGHIJK
1
2GOAL TIMESFIRST GOALSECOND GOAL
3HOMEAWAYHOMEAWAYTEAMHOMEAWAYTEAM
423 8323 HOME83HOME
517 45331733HOME45HOME
633 43 6833 HOME43HOME
79090 HOME 
87717 407717AWAY40AWAY
910 61271027HOME61HOME
1058 76645864HOME76HOME
114540 704540AWAY70AWAY
1231 52153115AWAY52HOME
137979 HOME 
14    
151682 901682HOME90AWAY
1614361436HOME 
1748 9048 HOME90HOME
1824 499 90249AWAY4990AWAY
192661 70 752661HOME70AWAY
2045 49 8945 HOME49HOME
Sheet1
Cell Formulas
RangeFormula
E4:F20E4=IF(B4="","",NUMBERVALUE(LEFT(B4,2)))
G4:G20G4=IF(AND(E4="",F4=""),"",IF(E4<F4,"HOME","AWAY"))
K4:K20K4=IF(AND(I4="",J4=""),"",IF(I4>J4,"HOME","AWAY"))
 
Upvote 0
After some searching, I have come up with this, which seems to be working. Would be interested if there are "cleaner" formulas to sue or if I've made any mistakes.

cheers


goaltimes.xlsm
ABCDEFGHIJKLM
1
2GOAL TIMESFIRST GOALSECOND GOAL
3HOMEAWAYHOMEAWAYTIMETEAMHOMEAWAYTIMETEAM
423 8323 23HOME83 83HOME
517 4533173317HOME45 45HOME
633 43 6833 33HOME43 43HOME
79090 90HOME    
87717 40771717AWAY 4040AWAY
910 6127102710HOME61 61HOME
1058 7664586458HOME76 76HOME
114540 70454040AWAY 7070AWAY
1231 5215311515AWAY52 52HOME
137979 79HOME    
14        
151682 90168216HOME 9090AWAY
161436143614HOME    
1748 9048 48HOME90 90HOME
1824 499 902499AWAY499049HOME
192661 70 75266126HOME 7070AWAY
203 6 893 3HOME6 6HOME
Sheet1
Cell Formulas
RangeFormula
E4:F20E4=IFERROR(NUMBERVALUE(INDEX(TEXTSPLIT(B4,," "),1)),"")
G4:G20,L4:L20G4=IF(MIN(E4:F4)=0,"",(MIN(E4:F4)))
H4:H20H4=IF(AND(E4="",F4=""),"",IF(E4<F4,"HOME","AWAY"))
J4:K20J4=IFERROR(NUMBERVALUE(INDEX(TEXTSPLIT(B4,," "),2)),"")
M4:M20M4=IF(L4="","",IF(L4=J4,"HOME","AWAY"))
 
Upvote 0
Here are some alternatives. Some are longer formulas than yours, but none of them need to be copied down the rows. Just put them in the row 4 cells & make sure the ranges in the formulas cover all the data rows.

BTW, is it possible that both teams could score within the same minute? If so, what should happen in the "TEAM" column?

25 02 27.xlsm
BCDEFGHIJKLM
1
2GOAL TIMESFIRST GOALSECOND GOAL
3HOMEAWAYHOMEAWAYTIMETEAMHOMEAWAYTIMETEAM
423 8323 23HOME83 83HOME
517 4533173317HOME4545HOME
633 43 683333HOME4343HOME
7909090HOME
87717 40771717AWAY4040AWAY
910 6127102710HOME6161HOME
1058 7664586458HOME7676HOME
114540 70454040AWAY7070AWAY
1231 5215311515AWAY5252HOME
13797979HOME
14
151682 90168216HOME9090AWAY
161436143614HOME
1748 904848HOME9090HOME
1824 499 902499AWAY499049HOME
192661 70 75266126HOME7070AWAY
203 6 8933HOME66HOME
Goals (2)
Cell Formulas
RangeFormula
E4:F20E4=IF(B4:B20="","",--TEXTBEFORE(B4:B20," ",,,1))
G4:G20,L4:L20G4=BYROW(E4:F20,LAMBDA(r,INDEX(SORT(r,,,1),1)))
H4:H20,M4:M20H4=BYROW(E4:G20,LAMBDA(r,IF(MAX(r),XLOOKUP(INDEX(r,3),r,E3:G3),"")))
J4:K20J4=LET(a,TEXTAFTER(TEXTBEFORE(B4:B20&" "," ",2,,1)," "),IFERROR(--a,a))
Dynamic array formulas.
 
Upvote 0

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