473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How can this code be modified to eliminate duplicates?

I am trying in excel to take a list of teams A through ? and group them into sets of three. I found a code that would do this, but now I need to eliminate any repeat use of combinations. For example if one set is ABC then I can not use the combinations with AB, AC or BC in them. If anyone can help I would appreciate it. It is for a youth basketball league and I am VB illiterate.
The code that I found is

[Sub FindSets()
Dim iA() As Integer
Dim sUniv As String
Dim iWanted As Integer
Dim j As Integer
Dim k As Integer

sUniv = Cells(1, 1).Value
iWanted = Cells(2, 1).Value

ReDim iA(iWanted)
For j = 1 To iWanted
iA(j) = j
Next j

iRow = PutRow(iA, sUniv, 1)

Do Until DoneYet(iA, Len(sUniv))
j = WorkHere(iA, Len(sUniv))
iA(j) = iA(j) + 1
For k = j + 1 To iWanted
iA(k) = iA(k - 1) + 1
Next k
iRow = PutRow(iA, sUniv, iRow)
Loop
End Sub

Function DoneYet(iB, n) As Boolean
iMax = UBound(iB)
Temp = True
For j = iMax To 1 Step -1
If iB(j) <> j + (n - iMax) Then
Temp = False
End If
Next
DoneYet = Temp
End Function

Function WorkHere(iB, n) As Integer
iMax = UBound(iB)
j = iMax
Do Until iB(j) <> j + (n - iMax)
j = j - 1
Loop
WorkHere = j
End Function

Function PutRow(iB, sUniv, i)
iMax = UBound(iB)
sTemp = ""
For j = 1 To iMax
sTemp = sTemp & Mid(sUniv, iB(j), 1)
Next j
Cells(i, 2).Value = sTemp
PutRow = i + 1
End Function]

I found this at http://excel.tips.net/Pages/T006766_Listing_Combinations.html
Jul 17 '10 #1
0 939

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Gianni Mariani | last post by:
The 3 compilers I tried all did different things. gcc 3.4.0 ICE's (Bug 15480) MS C++ 7.1 has meaningless diags Comeau accepts the code Obviously this is not somthing I'll be using until we...
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
1
by: GB | last post by:
Hello: I have a table like this: ID | AccNo -------------------------------- 1 0059 2 0059 3 0059 4 0194 5 0194
12
by: Martin Ho | last post by:
This is the code I have so far, to generate 50.000 random numbers. This code will generate the same sequence every time I run it. But the problem being is that it's slow. It take on my p4 1.6gh...
4
by: RON | last post by:
Can anyone tell me how I would fix this code to do the following? I want the buttons to be 0 through 9 not 1 through 10 like they are now. == Inherits System.Windows.Forms.Form Public...
53
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
52
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it...
30
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
1
by: jjmontreal | last post by:
I am trying to run this code in a form when a user double clicks in a particular field. I am unsure how I should do it since it uses 2 text files, one to generate and the other to store to eleminate...
3
by: AccessHunter | last post by:
Please help with writing a VBA Code to find duplicates from the following acces table. Fields:- TranDate, Job Num, Agency Name Date is like this, 1/3/2003, 757702, People Office...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.