Hi there
I need some help, to matching data!
eg: out of 20 elements: eg (10,2,4 17,24,5,30, 40, 50, 100, 23, 35, 200,
3501, 201, 245, 323,2000, 33, 44,265,etc)
I would want to know which of these elements eg: make up the sum 275??
in this example the combination: 245,30 = 275 ; 200,24,50 =275;
200,30,40,5 = 275 and so forth
Would I have to use vba code function and or could I us as well sql?
any hints are much appreciated
Regards
Norman
Klatuu - 22 Feb 2006 15:49 GMT
Interesting problem. I don't think SQL can do this; however, it is not my
strongest suit. It could be done with an array and some looping logic in
VBA. psuedo code:
Create an array of the numbers
Do Until AllDone
StartCounter = 0
NotFound = False
Do Until NotFound
LoopCounter = StartCounter + 1
TotNum = TotNum + Array(LoopCounter)
If TotNum = 275 Then
NotFound = True
AllDone = True
Else
LoopCounter = LoopCounter + 1
End If
If LoopCounter > Ubound(Array) Then
NotFound = True
End If
Loop
StartCounter = StartCounter + 1
If StartCounter > Ubound(Array) Then
AllDone = True
End If
Loop
The above may not be perfect, but it will give you an idea (I hope)
> Hi there
> I need some help, to matching data!
[quoted text clipped - 10 lines]
>
> Norman
Martin - 23 Feb 2006 15:56 GMT
The awkward bit is just crunching through every combination of a one
dimensional array. This might help
http://www.geocities.com/oosterwal/computer/combinations.html
> Interesting problem. I don't think SQL can do this; however, it is not my
> strongest suit. It could be done with an array and some looping logic in
[quoted text clipped - 39 lines]
> >
> > Norman
Tim Ferguson - 23 Feb 2006 17:52 GMT
"Norman Fritag" <muenchr@ozemail.com.au> wrote in news:43fc670f$1$12197
$5a62ac22@per-qv1-newsreader-01.iinet.net.au:
> I need some help, to matching data!
> eg: out of 20 elements: eg (10,2,4 17,24,5,30, 40, 50, 100, 23, 35, 200,
> 3501, 201, 245, 323,2000, 33, 44,265,etc)
> I would want to know which of these elements eg: make up the sum 275??
This is a one-line program in LISP... and I think there are versions of
LISP that you can embed within other applications.
Hope that helps
Tim F