I am trying to work out a way of doing a lookup whereby the formula/VBA returns a value for a given reference on sheet 1 if one or a combination of values with that reference on sheet 2 add up to a defined value with that reference on sheet 1. By way of example:
[TABLE="width: 351"]
<tbody>[TR]
[TD]Sheet one[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet two[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]Col A[/TD]
[TD="align: right"]Col B[/TD]
[TD][/TD]
[TD="align: right"]Col A[/TD]
[TD="align: right"]Col B[/TD]
[TD="align: center"]Col C[/TD]
[/TR]
[TR]
[TD]Reference[/TD]
[TD="align: right"]Amount £[/TD]
[TD][/TD]
[TD]Reference[/TD]
[TD="align: right"]Amount £[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]12345[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD="align: right"]12345[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]12346[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD="align: right"]12345[/TD]
[TD="align: right"]50[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD="align: right"]12347[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD="align: right"]12345[/TD]
[TD="align: right"]50[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12346[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12347[/TD]
[TD="align: right"]150[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12347[/TD]
[TD="align: right"]150[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
So, in the above example I want to be able to do a lookup in sheet 1 to sheet 2 for e.g. ref 12345 where the corresponding value/values for that reference in sheet 2 sum to the given value in sheet 1. So for ref 12345 I'm trying to get a formula that confirms that a combination of the amounts for ref 12345 in sheet 2 add up to £100 (even though the total for that reference is greater than £100).
I have worked out formula to tell me where the total for 12345 in sheet 2 is £100 but can't figure out how to show it where the total for a given reference is not equal to the target amount but a combination of items with that ref are.
If the above is possible I would also like to be able to show on sheet 2 those items in the list that add up to the target value in sheet 1. So in the example above, I am looking for a formula/VBA that would add in the '1s' in column C indicating that these amounts equal the target £100.
The spreadsheets I am working with have thousands of references and tens of thousands of repetitions (in sheet 2) so trying to manually match one sheet to the other isn't really an option. All suggestions gratefully received.
[TABLE="width: 351"]
<tbody>[TR]
[TD]Sheet one[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet two[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]Col A[/TD]
[TD="align: right"]Col B[/TD]
[TD][/TD]
[TD="align: right"]Col A[/TD]
[TD="align: right"]Col B[/TD]
[TD="align: center"]Col C[/TD]
[/TR]
[TR]
[TD]Reference[/TD]
[TD="align: right"]Amount £[/TD]
[TD][/TD]
[TD]Reference[/TD]
[TD="align: right"]Amount £[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]12345[/TD]
[TD="align: right"]100[/TD]
[TD][/TD]
[TD="align: right"]12345[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]12346[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[TD="align: right"]12345[/TD]
[TD="align: right"]50[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD="align: right"]12347[/TD]
[TD="align: right"]300[/TD]
[TD][/TD]
[TD="align: right"]12345[/TD]
[TD="align: right"]50[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12346[/TD]
[TD="align: right"]200[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12347[/TD]
[TD="align: right"]150[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"]12347[/TD]
[TD="align: right"]150[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
So, in the above example I want to be able to do a lookup in sheet 1 to sheet 2 for e.g. ref 12345 where the corresponding value/values for that reference in sheet 2 sum to the given value in sheet 1. So for ref 12345 I'm trying to get a formula that confirms that a combination of the amounts for ref 12345 in sheet 2 add up to £100 (even though the total for that reference is greater than £100).
I have worked out formula to tell me where the total for 12345 in sheet 2 is £100 but can't figure out how to show it where the total for a given reference is not equal to the target amount but a combination of items with that ref are.
If the above is possible I would also like to be able to show on sheet 2 those items in the list that add up to the target value in sheet 1. So in the example above, I am looking for a formula/VBA that would add in the '1s' in column C indicating that these amounts equal the target £100.
The spreadsheets I am working with have thousands of references and tens of thousands of repetitions (in sheet 2) so trying to manually match one sheet to the other isn't really an option. All suggestions gratefully received.