help with data matching required

N

Norman Fritag

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
 
G

Guest

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)
 
T

Tim Ferguson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top