Thread: Combination Sum
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 292
Default Combination Sum

Hi

This tests for one or two combinations. Put more loops inside the y loop
(like For z = y+1 to 700) for mo

Sub test()
Dim x As Long
Dim y As Long
Dim D1 As Double, D2 As Double
For x = 1 To 699
Application.StatusBar = x
D1 = Cells(x, 1).Value
If D1 = 8966 Then
MsgBox D1, , "Found one"
End If
For y = x + 1 To 700
D2 = Cells(y, 1).Value
If D1 + D2 = 8966 Then
MsgBox D1 & " " & D2, , "Found one"
End If
Next
Next
End Sub

HTH. Best wishes Harald

skrev i melding
...
Hi

I need help in solving for an issue in excel. A macro is required.

We have a list of 700 numbers and we need to find out how many
combinations match a particular number, if we add numbers from the
list of 700. Example:

List of numbers:
1234
63
8903
3446
8112
854
... and so on

Target: 8966

Solution:
Option 1:
8112+854
Option 2:
63+8903

Is this possible in excel macro. I found one here, but this is not
useful for more than 4 numbers.

http://en.allexperts.com/q/Excel-105...s-x-number.htm

I would appreciate it if a solution to this is available on excel or
any other software.