How to get individual cells to show remainders.

I'm currently working on making two separate sheets. One is where providers can submit that they have extra of something (someone submits that they have 5 extra bags of concrete, another person submits that they have 7 sheets of metal, etc.) with their email attached (so multiple of the same kind of material cant be combined). The other sheet is one where people can submit a request for a certain kind of material and will match them up with the other sheet.

The issue I am having is if a request is too big for one provider but can still be done through multiple providers, I want what is left to be reflected for each provider.

For example, someone needs 12 bags of concrete, but one person has 8 and another has 5. I want to subtract from their amounts and get their individual totals to reflect this, so that the one person would then have one and the other person would then have 0.

Also if there are a lot of individual providers for the same material, I would prefer to use the least amount of providers as well.

Is there a way to write a formula to do something like this? I am open to using as many helper columns as necessary as the main way of interacting with these two sheets are going to be forms.

Tags: