Formula/VBA for lookup to return a value if a combination of items in a list equal a defined value

JWill78

New Member
Joined
Feb 13, 2015
Messages
8
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:

Sheet oneSheet two
Col ACol BCol ACol BCol C
ReferenceAmount £ReferenceAmount £
123451001234520
1234620012345501
1234730012345501
12346200
12347150
12347150

<tbody>
</tbody>


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.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,110
Messages
6,123,147
Members
449,098
Latest member
Doanvanhieu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top