Lookup Result Needed

PM1

Board Regular
Joined
Oct 28, 2005
Messages
192
Hi, I have a table below that lists 17 people who play with different people over 4 days

Pl/Day 1 2 3 4
A N I M H
B M J L I
C L K J O
D K L I M
E J M K N
F I N H K
G H O E P
H G P F Q
I F Q G L
J E A D B
K D C O A
L C B A D
M B D Q C
N A E B F
O Q F P E
P O G Q J
Q P H C G


From the above table how can I construct a lookup table that reports a playing table as below:

A B C D E F G H I J K L M N
A 4 2 3 1
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
If your first table is in the range A1:E18 on Sheet 1 and your second table is in the range A1:R18 on another sheet, in B2 enter:

=IF(COUNTIF(INDEX(Sheet1!$B$2:$E$18,MATCH($A2,Sheet1!$A$2:$A$18),0),B$1),INDEX(Sheet1!$B$1:$E$1,MATCH(B$1,INDEX(Sheet1!$B$2:$E$18,MATCH($A2,Sheet1!$A$2:$A$18),0),FALSE)),"")

and copy down and across.
 
Upvote 0
Andrw,

Is there a way I can randomise the first table. At present I constructed it by trial an error without any real logic. If I need to change it around I then stuggle with the rest of the table.
 
Upvote 0
What do you mean by randomise? If you mean have it with column A unsorted, change the formula to:

=IF(COUNTIF(INDEX(Sheet1!$B$2:$E$18,MATCH($A2,Sheet1!$A$2:$A$18,FALSE),0),B$1),INDEX(Sheet1!$B$1:$E$1,MATCH(B$1,INDEX(Sheet1!$B$2:$E$18,MATCH($A2,Sheet1!$A$2:$A$18,FALSE),0),FALSE)),"")
 
Upvote 0
This is for Table 1, the formula you gave me for table 2 is fine.

As I stated, in Table 1 I have manually alloctaed the letters that appear. It is those letters that i want generated in that no letter can be associated with the same letter twice
 
Upvote 0
OK - Lets see if this works. Here is the table I have
Excel Workbook
HIJKLMNOP
1****Player/DayThFri amFri pmSat
2AAlex Hickson13*A****
3BRoy Button21*B****
4CAlaistair Pinney28*C****
5DAndy Ockendon25*D****
6EMorris Gwilt23*E****
7FDave Creak28*F****
8GAndy Parfitt13*G****
9HHowell Roberts12*H****
10ISteve Milner23*I****
11JHugh Laurie24*J****
12KAndrew Emmett20*K****
13LMartin Desmond26*L****
14MStewart Parfitt15*M****
15NSteve Berg31*N****
16ORobert Bertram21*O****
17PGiles Marshall20*P****
18QJohn Chittock11*Q****
Sheet3


I want to randomly generate a schedule in M2:P18 in that no player is aligned with another player more than once.

I've tried Random but that doesn't seem to work, not sure on what else does
 
Upvote 0
Hi,

Andrew-R come up with this solution:-

Sub BuildSchedule()

Const lTEES = 17
Const lPLAYERS = 17
Const lFOURSLOTS = 8

Const lFIRST_DATA_ROW = 1
Const lNAME_COL = 6
Const lCOUNT_COL = 7
Const lFIRST_SLOT_COL = 2

Dim lSlots As Long
Dim lTeeLoop As Long
Dim lSlotLoop As Long
Dim rngCountRange As Range
Dim bSlotFilled As Boolean
Dim lInnerLoop As Long
Dim sRowValue(1 To lTEES) As String
Dim sPlayer As String
Dim lCheckLoop As Long
Dim bComboExists As Boolean
Dim lInnerCheckLoop As Long
Dim sToken As String

With ActiveSheet

Set rngCountRange = .Range(.Cells(lFIRST_DATA_ROW, lCOUNT_COL), .Cells(lFIRST_DATA_ROW + lPLAYERS - 1, lCOUNT_COL))

For lTeeLoop = 1 To lTEES

sRowValue(lTeeLoop) = ""

If lTeeLoop <= lTEES - lFOURSLOTS Then
lSlots = 3
Else
lSlots = 4
End If

For lSlotLoop = 1 To lSlots

bSlotFilled = False
lInnerLoop = 1

While Not bSlotFilled And lInnerLoop <= lPLAYERS
sPlayer = .Cells(lFIRST_DATA_ROW + lInnerLoop - 1, lNAME_COL).Value
sToken = Chr(64 + lInnerLoop)
If rngCountRange.Rows(lInnerLoop).Value = Application.WorksheetFunction.Min(rngCountRange) Then
If lSlotLoop = 1 Or lTeeLoop = 1 Then
.Cells(lFIRST_DATA_ROW + lTeeLoop - 1, lFIRST_SLOT_COL + lSlotLoop - 1).Value = sPlayer
sRowValue(lTeeLoop) = sRowValue(lTeeLoop) & sToken
bSlotFilled = True
Else
bComboExists = False
lCheckLoop = 1

While Not (bComboExists) And lCheckLoop < lTeeLoop
For lInnerCheckLoop = 1 To Len(sRowValue(lTeeLoop))
If InStr(sRowValue(lCheckLoop), Mid(sRowValue(lTeeLoop), lInnerCheckLoop, 1)) > 0 And InStr(sRowValue(lCheckLoop), sToken) > 0 Then
bComboExists = True
Else
'lCheckLoop = lCheckLoop + 1
End If
Next lInnerCheckLoop
lCheckLoop = lCheckLoop + 1
Wend

If Not bComboExists Then
.Cells(lFIRST_DATA_ROW + lTeeLoop - 1, lFIRST_SLOT_COL + lSlotLoop - 1).Value = sPlayer
sRowValue(lTeeLoop) = sRowValue(lTeeLoop) & sToken
bSlotFilled = True
Else
lInnerLoop = lInnerLoop + 1
End If
Application.Calculate
End If
Else
lInnerLoop = lInnerLoop + 1
End If
Wend
Next lSlotLoop
Next lTeeLoop

End With

End Sub

Problem is that it allows for duplicates in the columns, can anybody amend to stop this?
 
Upvote 0
This was the table that I used to test the above Macro

Excel Workbook
ABCDEFG
11MikeEricAndyAndy4
22JohnCharlesAndyBrian4
33GeorgeDaveOscarCharles4
44FredOscarIanDave4
55EricGeorgeBrianEric4
66MikeBrianPeterFred3
77AndyIanDaveGeorge3
88JohnNormEricHenry4
99CharlesDaveHenryIan4
1010CharlesKevinEricFredJohn4
1111GeorgeJohnHenryMikeKevin3
1212QuentinIanJohnKevinLiam4
1313NormAndyBrianQuentinMike3
1414CharlesPeterIanLiamNorm2
1515KevinDaveLiamLiamOscar3
1616OscarPeterHenryQuentinPeter3
1717FredBrianHenryLiamQuentin3
Sheet1
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,896
Members
452,948
Latest member
Dupuhini

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