Remove Duplicate Combinations

JoJoBug85

New Member
Joined
Oct 22, 2015
Messages
2
Hi All,

I am trying to compile a list of optimal fantasy football lineups, but I am running into a duplicate issue. I am able to have 3 wide-receivers playing in my lineup. I identified what I think are the top 75 wide receivers and plugged them in to Access to find all 405,150 possible combinations where WR1<>WR2 and WR3<>WR2 or WR1. The problem is that I then have each possible combination listed 6 times:

WR1
WR2
WR3
Antonio Brown
Larry Fitzgerald
Martavis Bryant
Antonio Brown
Martavis Bryant
Larry Fitzgerald
Larry Fitzgerald
Antonio Brown
Martavis Bryant
Larry Fitzgerald
Martavis Bryant
Antonio Brown
Martavis Bryant
Antonio Brown
Larry Fitzgerald
Martavis Bryant
Larry Fitzgerald
Antonio Brown

<tbody>
</tbody>

I have been wracking my brain and combing the internet, but must somehow not be searching for the right thing. I can't be the only person who has ever had this problem. I'm willing to do the work, but do you have any suggestions as to how I might isolate one of the combinations from each set of six and eliminate the five 'duplicates' to get down to the ~67,500 that I actually want? I'm fairly comfortable with excel/vba and access/modules, so I'm open to anything that gets me headed in the right direction.

Thanks in advance!!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
See if this works for you.
Code:
Sub kalx()

Dim Qix As Object, a, i As Long, r As Long, rs As Long
Set Qix = CreateObject("scripting.dictionary")
Set a = Range("A1").CurrentRegion.Resize(, 3)

For i = 2 To a.Rows.Count
    a.Rows(i).Sort a(i, 1), Header:=xlNo, Orientation:=xlLeftToRight
    Qix(Join(Array(a(i, 1), a(i, 2), a(i, 3)), Chr(2))) = 1
Next i

a.Offset(1).ClearContents: r = 1
For Each c In Qix.keys
    r = r + 1
    a(r, 1).Resize(, 3) = Split(c, Chr(2))
Next c

End Sub
 
Upvote 0
Another approach is to avoid duplicates.
I have the following formula solution to compile a list of 3 indices 1-75 without duplicates.
A2=1, B2=2, C2=3
A3: =IF(AND(B2=74,C2=75),A2+1,A2)
B3: =IF(C2=75,IF(B2=74,A2+1,B2+1),B2)
C3: =IF(C2=75,B3+1,C2+1)
Copy formulas from row 3 down thru row 70,226 for all combinations.
With INDEX you can create columns with names for the indices.
 
Upvote 0
You are all wonderful! Both solutions (the second one with the fix added in to remove duplicates in columns A and B) worked wonderfully. I turned off screen updating on the vba and it ran like a charm. Now on to the rest of my lineup :biggrin: Thank you so much for your quick and helpful suggestions!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

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