Best cost for same item in subsequent rows and return that value

rick8899

New Member
Joined
Sep 6, 2012
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I am looking for a formula or vba to find the cost for a single item that has data on 1-3 rows of price plan data. Then it would need to return the item number with the lowest cost and plan.

Test Page1.xlsx
ABCDEFG
2Formula picks the best cost for each item and lists it on the right side
3
4Raw DataAfter formula is applied
5Stock NumberCostPrice PlanStock NumberCostPrice Plan
6LEO745414.85GL8LEO745414.3517A
7LEO745414.3517ALEO76310ST57.45GL8
8LEO76310ST57.45GL8LEO76350ST55.0117A
9LEO76350ST64.55GL8LEO76365ST60.71W0I
10LEO76350ST55.0117ALEO771063.28W0I
11LEO76365ST108.92GL8
12LEO76365ST60.71W0I
13LEO771064.7817A
14LEO771063.28W0I
15LEO771065.71GL8
Sheet1
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,
Which version of Excel are you using? You should update your Account Details.
 
Upvote 0
Hi,

If you are using 365, here is one way:

=LET(a,SORT(UNIQUE(A6:A15)),b,MAP(a,LAMBDA(x,MINIFS(B6:B15,A6:A15,x))),c,MAP(a,b,LAMBDA(x,y,FILTER(C6:C15,(A6:A15=x)*(B6:B15=y)))),CHOOSE({1,2,3},a,b,c))

Sure, there will be more elegant way.
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Another option if you have 365
Fluff.xlsm
ABCDEFG
1Stock NumberCostPrice PlanStock NumberCostPrice Plan
2LEO745414.85GL8LEO745414.3517A
3LEO745414.3517ALEO76310ST57.45GL8
4LEO76310ST57.45GL8LEO76350ST55.0117A
5LEO76350ST64.55GL8LEO76365ST60.71W0I
6LEO76350ST55.0117ALEO771063.28W0I
7LEO76365ST108.92GL8
8LEO76365ST60.71W0I
9LEO771064.7817A
10LEO771063.28W0I
11LEO771065.71GL8
Data
Cell Formulas
RangeFormula
F2:G6F2=TAKE(SORT(FILTER($B$2:$C$11,$A$2:$A$11=E2)),1)
Dynamic array formulas.
 
Upvote 0
Solution
Hi,

If you are using 365, here is one way:

=LET(a,SORT(UNIQUE(A6:A15)),b,MAP(a,LAMBDA(x,MINIFS(B6:B15,A6:A15,x))),c,MAP(a,b,LAMBDA(x,y,FILTER(C6:C15,(A6:A15=x)*(B6:B15=y)))),CHOOSE({1,2,3},a,b,c))

Sure, there will be more elegant way.
Thank you for the example.
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Another option if you have 365
Fluff.xlsm
ABCDEFG
1Stock NumberCostPrice PlanStock NumberCostPrice Plan
2LEO745414.85GL8LEO745414.3517A
3LEO745414.3517ALEO76310ST57.45GL8
4LEO76310ST57.45GL8LEO76350ST55.0117A
5LEO76350ST64.55GL8LEO76365ST60.71W0I
6LEO76350ST55.0117ALEO771063.28W0I
7LEO76365ST108.92GL8
8LEO76365ST60.71W0I
9LEO771064.7817A
10LEO771063.28W0I
11LEO771065.71GL8
Data
Cell Formulas
RangeFormula
F2:G6F2=TAKE(SORT(FILTER($B$2:$C$11,$A$2:$A$11=E2)),1)
Dynamic array formulas.
This works perfectly! Thank you!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
This works perfectly! Thank you!
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,215,360
Messages
6,124,493
Members
449,166
Latest member
hokjock

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