Thanks a lot!!!

Well, I looked at the macro and its' not what I want. 

I thought through and came up with a following code..  ( just testing code) 

In this example, there are five values: 12.25, 10.3, 24.3, 23.19, 55.2
And I need to find any combination of values above which sum up to ... let's 
say 34.6. 

Sub Test()

Dim Ob_N(1 To 5) As Variant

Ob_N(1) = 12.25
Ob_N(2) = 10.3
Ob_N(3) = 24.3
Ob_N(4) = 23.19
Ob_N(5) = 55.2


Seeking_sum_amount = 34.6

For i = 1 To 5

For j = i + 1 To 5

If Ob_N(i) + Ob_N(j) = Seeking_sum_amount Then

ActiveCell.Value = Ob_N(i)
ActiveCell.Offset(0, 1) = Ob_N(j)
ActiveCell.Offset(1, 0).Select
End If

Next
Next
End Sub

Now, the problem of this testing code is that it only looks at the 
combination of 2 values... 
I can add another for...next for three combination ...   
and add another for four 4 combination test 

but I'm wondering  if there is a way to do up to 4 combination test if 
number of given values are 4..     if number of given values is 6 then up to 
5 combination test..  and so on..  

To sum up, macro determines how many values are given.  --->  ubound(Ob_n) 
run the combination test up to ubound(ob_n) - 1 and find any combination 
which sum up to a specified value. 

any good way of doing this??? 


-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to