Help with a fighting simulation

Auranim

New Member
Joined
May 16, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi! I'm developing a system in which I need to pit participants against each other. For that, I have a list with 4 participants like such

# | Participant name
1 | John
2 | Michael
3 | Erik
4 | Dennis

I need to create a table that automatically shows each match, as such:

John | v.s.| Michael
John | v.s. | Erik
John | v.s. | Dennis
Michael | v.s. | Erik
Michael | v.s. | Dennis
Erik | v.s. | Dennis

I've been doing this manually but sometimes there will be more participants or fewer participants, so it would be great to create two formulas I can extend all the way down my spreadsheet that encompasses every possible match. The order of the matches doesn't matter, the only thing that matters is, in the end, every participant must have fought everyone else only once.
 
Sorry, it is my mistake...i forgot -1 for the formula in D2. please test below formulas:
Cell Formulas
RangeFormula
C2:C11C2=IFERROR(SMALL(IF(TRANSPOSE(ROW(Table1[Participant name]))>ROW(Table1[Participant name]),ROW(Table1[Participant name]),""),ROW(A1)),"")
D2:D11D2=IFERROR(INDEX(Table1[Participant name],C2-1),"")
E2:E11E2=IF(D2<>"","| v.s.|","")
F2:F11F2=IFERROR(INDEX(Table1[Participant name],C2+COUNTIF(C$1:C1,C2)),"")

One last thing. Is there any way to do with using cell ranges instead of dynamic tables?
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
yes, OFFSET is OK.
Cell Formulas
RangeFormula
C2:C20C2=IFERROR(SMALL(IF(TRANSPOSE(ROW(OFFSET($A$2,,,COUNTA(A:A)-1,)))>ROW(OFFSET($A$2,,,COUNTA(A:A)-1,)),ROW(OFFSET($A$2,,,COUNTA(A:A)-1,)),""),ROW(A1)),"")
D2:D20D2=IFERROR(INDEX(OFFSET($A$2,,,COUNTA(A:A)-1,),C2-1),"")
E2:E20E2=IF(D2<>"","| v.s.|","")
F2:F20F2=IFERROR(INDEX(OFFSET($A$2,,,COUNTA(A:A)-1,),C2+COUNTIF(C$1:C1,C2)),"")
 
Upvote 0
Huh, that's odd. Those ones didn't work for me. They just give me blank cells :/
 
Upvote 0
are you using office 365? if not, use CTRL+SHIFT+ENTER for the array formula in column C.
I am using 365. What I did was install Excel in English (not my first language). Soon as I did it, it worked :P Thanks a lot hahaha for the formulas and for the patience! <3
 
Upvote 0
Another option you could try without the volatile function OFFSET & some simpler formulas.
You can, of course, hide the helper column once it has its formulas

Auranim 2020-05-17 1.xlsm
ABCDEFG
1Participant name4Participant 1Participant 2
2John1John|v.s.|Michael
3Michael1John|v.s.|Erik
4Erik1John|v.s.|Dennis
5Dennis2Michael|v.s.|Erik
62Michael|v.s.|Dennis
73Erik|v.s.|Dennis
8    
9    
10    
11    
12    
13    
Sheet1
Cell Formulas
RangeFormula
D1D1=COUNTA(A:A)-1
D2:D13D2=IF(D1=D$1,1,IF(LOOKUP(D$1,D$1:D1)=D$1-1,"",IF(COUNTIF(D$1:D1,D1)<=D$1-COUNT(UNIQUE(D$1:D1)),D1,D1+1)))
E2:E13E2=IF(D2="","",INDEX(A:A,D2+1))
F2:F13F2=IF(D2="","","|v.s.|")
G2:G13G2=IF(D2="","",INDEX(A:A,D2+1+COUNTIF(D$2:D2,D2)))



After adding an extra participant:
 
Upvote 0
Another option you could try without the volatile function OFFSET & some simpler formulas.
You can, of course, hide the helper column once it has its formulas

Auranim 2020-05-17 1.xlsm
ABCDEFG
1Participant name4Participant 1Participant 2
2John1John|v.s.|Michael
3Michael1John|v.s.|Erik
4Erik1John|v.s.|Dennis
5Dennis2Michael|v.s.|Erik
62Michael|v.s.|Dennis
73Erik|v.s.|Dennis
8    
9    
10    
11    
12    
13    
Sheet1
Cell Formulas
RangeFormula
D1D1=COUNTA(A:A)-1
D2:D13D2=IF(D1=D$1,1,IF(LOOKUP(D$1,D$1:D1)=D$1-1,"",IF(COUNTIF(D$1:D1,D1)<=D$1-COUNT(UNIQUE(D$1:D1)),D1,D1+1)))
E2:E13E2=IF(D2="","",INDEX(A:A,D2+1))
F2:F13F2=IF(D2="","","|v.s.|")
G2:G13G2=IF(D2="","",INDEX(A:A,D2+1+COUNTIF(D$2:D2,D2)))



After adding an extra participant:

There we go. It works 100% the way I needed! Brilliant, thank you SO much! <3
 
Upvote 0
use simpler formulas for no more than 7 participants.
Cell Formulas
RangeFormula
C2:C20C2=TEXT(COUNTA(A:A)-ROUND(SQRT(ROW(A1)*2),),"[>1]0;;")
D2:D20D2=IF(C2="","",INDEX(A:A,C2))
E2:E20E2=IF(D2<>"","| v.s.|","")
F2:F20F2=IF(C2="","",INDEX(A:A,C2+COUNTIF(C$2:C2,C2)))
 
Upvote 0
For any number of participants (provided formulas are copied down far enough) with simple formulas. Assuming that you would hide the helper column.

Cell Formulas
RangeFormula
D1D1=COUNTA(A:A)-1
D2:D48D2=D1-OR(COUNTIF(D$1:D1,D1)=D1,D1=D$1)
E2:E48E2=IF(D2=0,"",INDEX(A:A,D2+2))
F2:F48F2=IF(E2="","","|v.s.|")
G2:G48G2=IF(F2="","",INDEX(A:A,D2+2-COUNTIF(D$2:D2,D2)))
 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,227
Members
453,025
Latest member
Hannah_Pham93

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