Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find total number of unique model numbers Brian Excel Worksheet Functions 8 September 19th 08 05:51 AM
Function To Lookup Unique Records In 2 Sets Of Data James Al Excel Worksheet Functions 2 January 18th 08 08:00 PM
Finding unique names--then converting those names to unique number Proton Excel Discussion (Misc queries) 7 June 13th 07 10:22 PM
merge two data sets one unique CESTOTT Excel Discussion (Misc queries) 2 January 25th 06 03:45 PM
Finding unique numbers in a column coolkid397 Excel Discussion (Misc queries) 3 June 15th 05 07:53 AM


All times are GMT +1. The time now is 01:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"