Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding unique sets of numbers that total 200
I have a list of 25 unique numbers, that are all less than
100. I am trying to figure out how many different sets of those numbers equal a sum of 200. The set has to consist of four number. For example, one set would be 5, 11, 89, 95. There are many more, but is there a way excel can use a function or scenario to figure it out? Thanks, Jeff |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding unique sets of numbers that total 200
You could write a macro to do it:
Sub AddThemUp() Dim i As Integer, j As Integer, k As Integer, m As Integer For i = 1 To 22 For j = i + 1 To 23 For k = j + 1 To 24 For m = k + 1 To 25 If Cells(i, 1) + Cells(j, 1) + Cells(k, 1) + Cells(m, 1) = 200 Then Union(Cells(i, 1), Cells(j, 1), Cells(k, 1), Cells(m, 1)).Select Exit Sub End If Next Next Next Next End Sub Assumes the numbers are in A1:A25. -- Vasant "Jeff" wrote in message ... I have a list of 25 unique numbers, that are all less than 100. I am trying to figure out how many different sets of those numbers equal a sum of 200. The set has to consist of four number. For example, one set would be 5, 11, 89, 95. There are many more, but is there a way excel can use a function or scenario to figure it out? Thanks, Jeff |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Finding unique sets of numbers that total 200
Trying it again; will hopefully avoid the line wrap:
Sub AddThemUp() Dim i As Integer, j As Integer, k As Integer, m As Integer For i = 1 To 22 For j = i + 1 To 23 For k = j + 1 To 24 For m = k + 1 To 25 If Cells(i, 1) + Cells(j, 1) + Cells(k, 1) _ + Cells(m, 1) = 200 Then Union(Cells(i, 1), Cells(j, 1), Cells(k, 1), _ Cells(m, 1)).Select Exit Sub End If Next Next Next Next End Sub "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... You could write a macro to do it: Sub AddThemUp() Dim i As Integer, j As Integer, k As Integer, m As Integer For i = 1 To 22 For j = i + 1 To 23 For k = j + 1 To 24 For m = k + 1 To 25 If Cells(i, 1) + Cells(j, 1) + Cells(k, 1) + Cells(m, 1) = 200 Then Union(Cells(i, 1), Cells(j, 1), Cells(k, 1), Cells(m, 1)).Select Exit Sub End If Next Next Next Next End Sub Assumes the numbers are in A1:A25. -- Vasant "Jeff" wrote in message ... I have a list of 25 unique numbers, that are all less than 100. I am trying to figure out how many different sets of those numbers equal a sum of 200. The set has to consist of four number. For example, one set would be 5, 11, 89, 95. There are many more, but is there a way excel can use a function or scenario to figure it out? Thanks, Jeff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find total number of unique model numbers | Excel Worksheet Functions | |||
Function To Lookup Unique Records In 2 Sets Of Data | Excel Worksheet Functions | |||
Finding unique names--then converting those names to unique number | Excel Discussion (Misc queries) | |||
merge two data sets one unique | Excel Discussion (Misc queries) | |||
Finding unique numbers in a column | Excel Discussion (Misc queries) |