Hi Conrad
Have you had a look at "Tools\Goal Seeker" or "Tools\Scenarios" o
"Tools\Solver" functions to see if they able to provide a solution?
If not, there are 2 other possible methods that you may wish to try.
The first is formula based and assumes that ..
A. The list is very short (As per your example)
B. The set value is in cell D2
This is a rather cumbersome (and dirty) method which requires that yo
have multiple 'staging' formulae before you get a final result.
Test whether the value in cell A1 is a valid candiate with thi
formula.
=IF(A1=D2,"a1",IF(A1+A2=D2, "a1 and a2", IF(A1+A3=D2,"a1 and a3"
IF(A1+A3=D2,"a1 and a3",IF(A1+A4=D2,"a1 and a4","Not Valid"))))
Now test whether the value in cell A2 is a valid candiate (In anothe
cell) with this formula.
=IF(A2=D2,"a2",IF(A2+A3=D2,"a2 and a3", IF(A2+A4=D2,"a2 and a4", "No
Valid")))
Test cells A3 and A4 respectively.
Finally, lookup the results where the value is <> "Not Valid"
The other solution requires a bit of code in a macro as follows.
Sub MyTest()
Dim MySetValue, MyFirstCell As Range
Dim MyValue1, MyValue2, MyTotal, MyRowCounter As Integer
MySetValue = Range("D2")
MyRowCounter = 1
Range("A1").Activate
Do While ActiveCell <> ""
MyRef = ActiveCell.Address
MyValue1 = ActiveCell
If MyValue1 = MySetValue Then
Range("D3") = MyRef
Exit Sub
Else
ActiveCell.Offset(1, 0).Activate
End If
Do While ActiveCell <> ""
MyTotal = MyValue1 + ActiveCell
If MyTotal = Range("D2") Then
MyRef = MyRef & " and " & ActiveCell.Address
Range("D3") = MyRef
Exit Sub
Else
ActiveCell.Offset(1, 0).Activate
End If
Loop
Range(MyRef).Activate
ActiveCell.Offset(1, 0).Activate
Loop
End Su