Vlookup? with optimum pricing based on quantities

owj

New Member
Joined
Mar 18, 2013
Messages
1
Hello
The Scenario:
the company I work for have four main customers who near the end of every month will e-mail a list of the stock they want, the maximum quantity they can accept and the price they can afford to pay per unit.

Say for example we have 28 units of one item and the customers have emailed us to saying this

customer 1 --> 10 units at £54.10/ea
customer 2 --> 100 units at £53.90/ea
customer 3 --> 15 units at £54.50/ea
customer 4--> 50 units at £52.50/ea

Now currently in the excel template I am trying to create I have a space for the total number of stock we have (in the example 28) and a two columns for each customer, one saying the price and another with the quantity. This could be a master style sheet and 4 more sheets each one with a blank invoice on it waiting for it to be populated by the stock they can pay the most for.

Obviously, as a company we want to sell as many as we can for the highest price so we would sell 15 to customer 3 for £54.50/ea, 10 to customer 1 for £54.10/ea and the remaining three to customer 2 for £53.90/ea

So my question is, how would I be able to make excel to rank the data so that the customer who is prepared to pay the most gets up to their maximum quantity and the rest (upto the max) goes to the other customers

Any suggestions?
Currently i have just created a table no formulas at all currently!
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Can you not just sort descending by price and allocate from the top?
 
Upvote 0
If you want to go the formula route you can try the layout I have below:


Excel 2010
ABCDEFGHI
1Stock Levels28
2Customer NameSend x unitsUnits remainingPrice
3Customer NameRequired UnitsPrice per UnitPrice Rank28
4Customer 110£54.102Customer 31513£817.50
5Customer 2100£53.903Customer 1103£541.00
6Customer 315£54.501Customer 230£161.70
7Customer 450£52.504Customer 400£0.00
8TOTAL28£1,520.20
Sheet1
Cell Formulas
RangeFormula
D4=RANK($C4, $C$4:$C$7)
H3=$B$1
F4=INDEX($A$4:$A$7, MATCH(ROW($D1), $D$4:$D$7, 0))
G4=IF($H3 >= INDEX($B$4:$B$7,MATCH(ROW($D1), $D$4:$D$7, 0)), INDEX($B$4:$B$7, MATCH(ROW($D1), $D$4:$D$7, 0)),$H3)
I4=$G4 * INDEX($C$4:$C$7, MATCH(ROW($D1), $D$4:$D$7, 0))


The left side contains all of your static data, with a rank column so that we know which customer has the highest rate.
Then the right side has a number of formulas which use this rank to calculate who gets what units. Just realised this will hit a small snag if 2 customers offer the same rate. I'll try and sort something for you that fixes that. But if all the rates offered are unique then this will work.

Hope this helps!
 
Upvote 0
The formulas below sort the same rate issue. All that needed changing was the rank formula so that it pulled out the correct ranks. This does mean however that if 2 customers offer the same rate, then the customer that comes first in the list will get their units allocated first.


Excel 2010
ABCDEFGHI
1Stock Levels28
2Customer NameRequired UnitsPrice per UnitPrice RankCustomer NameSend x unitsUnits remainingPrice
3028
4Customer 110£54.102Customer 31513£817.50
5Customer 2100£53.903Customer 1103£541.00
6Customer 315£54.501Customer 230£161.70
7Customer 450£52.504Customer 400£0.00
8TOTAL28£1,520.20
Sheet1
Cell Formulas
RangeFormula
D4=RANK($C4, $C$4:$C$7) + COUNTIF(D3:$D$3, RANK($C4, $C$4:$C$7))
H3=$B$1
F4=INDEX($A$4:$A$7, MATCH(ROW($D1), $D$4:$D$7, 0))
G4=IF($H3 >= INDEX($B$4:$B$7,MATCH(ROW($D1), $D$4:$D$7, 0)), INDEX($B$4:$B$7, MATCH(ROW($D1), $D$4:$D$7, 0)),$H3)
I4=$G4 * INDEX($C$4:$C$7, MATCH(ROW($D1), $D$4:$D$7, 0))
 
Upvote 0
Realised you might not be able to see all formulas. Hopefully this is my final post :)


Excel 2010
ABCDEFGHI
1Stock Levels28
2Customer NameRequired UnitsPrice per UnitPrice RankCustomer NameSend x unitsUnits remainingPrice
3028
4Customer 110£54.102Customer 31513£817.50
5Customer 2100£53.903Customer 1103£541.00
6Customer 315£54.501Customer 230£161.70
7Customer 450£52.504Customer 400£0.00
8TOTAL28£1,520.20
Sheet1
Cell Formulas
RangeFormula
D4=RANK($C4, $C$4:$C$7) + COUNTIF(D3:$D$3, RANK($C4, $C$4:$C$7))
H3=$B$1
H4=IF($H3 - $G4 < 0, 0, $H3 - $G4)
F4=INDEX($A$4:$A$7, MATCH(ROW($D1), $D$4:$D$7, 0))
G4=IF($H3 >= INDEX($B$4:$B$7,MATCH(ROW($D1), $D$4:$D$7, 0)), INDEX($B$4:$B$7, MATCH(ROW($D1), $D$4:$D$7, 0)),$H3)
G8=SUM(G4:G7)
I4=$G4 * INDEX($C$4:$C$7, MATCH(ROW($D1), $D$4:$D$7, 0))
I8=SUM(I4:I7)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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