Excel Matching Function for distinct values related to particular rows/columns.

AbsentStream

New Member
Joined
Jan 21, 2019
Messages
6
Hi Guys

Having a problem with the Index matching function on excel.

I'm using a SMALL IF function to pull the smallest 10 figures from one sheet to another and then using index matching to take these figures and pull a particular code associated to that figure from the sheet (The code and the figure are in the same row in the sheet FYI). This works for where we have values which don't have duplicates in the sheet fine. The problem that's popping up is that some values are the same but have different codes and I don't know how to distinguish which code Is the one we're looking at for that particular figure using an excel function.

For example, '0' is a figure which pops up a lot but the index matching function I'm using only returns one code for all '0' values from the sheet, rather than the one associated with that code.

Is there a way of making the index function or the small if function pull in the row/column to which it is pulling that figure from so we can match it to a code? Or is there a better way to go about this?

Appreciate Any Detailed Help With This,

Absent.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Without knowing your layout, how about something like


Excel 2013/2016
ABCDE
1xy
21abc0defdef
30def0pqrpqr
45ghi0stustu
57jkl1abcabc
69mno3vwxvwx
70pqr5ghighi
80stu7jkljkl
93vwx9mnomno
Orders
Cell Formulas
RangeFormula
C2=SMALL(A$2:A$9,ROWS(A$2:A2))
E2=IFERROR(INDEX($B$2:$B$9,AGGREGATE(15,6,(ROW($B$2:$B$9)-ROW($B$2)+1)/($A$2:$A$9=C2),COUNTIF($C$2:C2,C2))),"")
D2{=INDEX($B$2:$B$9,SMALL(IF($A$2:$A$9=C2,ROW($B$2:$B$9)-1),COUNTIF(C$2:C2,C2)))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
Cheers Fluff!

I think this should work just fine. I'll be able to check it out with the data I'm using tomorrow but seems to do exactly what I need it to do in this example.

A1 for the speedy response also!

Cheers,
Absent.
 
Upvote 0
You're welcome & thanks for the feedback.
Let me know if there's any problems
 
Upvote 0
Hi Fluff, this works very well.

Just one slight problem, say we add another column with people's names as variable Z in your example above.

Is there a way of altering the worksheet formula so that it can group per name as well? Otherwise, using the above example, I'm left with some duplicates as it seems to reuse the same code it's already used for some of the numbers where they're the same as previous ones.

I have tried for example: =IFERROR(INDEX($B$2:$B$9,AGGREGATE(15,6,(ROW($B$2:$B$9)-ROW($B$2)+1)/($A$2:$A$9=C2)/($F$2::$F$9 = E2),COUNTIF($C$2:C2,C2))),"") (Assuming E2 is the name we want to look at and F1:F9 is the list of names) but this seems to just skip over values that have already been used and not input them into the cell.

 
Upvote 0
Please See below fluff (was not able to download any from that link).

So I want to group the 5 smallest figures for each name in this example. (Amalgamating Tom and Tom2 together to show the smallest 5 across both as 'TOM')

Then using them figures, I want it to pull the associated code from column B into cell G.

The worksheet formula you used above works to some extent but still seeing the dupe problem.

NameCodeNumber NAMENUMBERCODE
JOHN AB-10 JOHN
JOHN CD-2 JOHN
JOHN EF0 JOHN
JOHN GH0 JOHN
JOHN IJ2 JOHN
JOHN KL6
JOHNMN8 PAT
JOHN OP10 PAT
PATQR-8 PAT
PATST-2 PAT
PATUV0 PAT
PATWX0
PATYZ3 TOM
PATABC6 TOM
PATDEF8 TOM
PATGHI8 TOM
PATJKL11 TOM
PATMNO12
PATPQR14
TOMBLUE-2
TOMRED0
TOMYELLOW4
TOMPURPLE6
TOMBLACK12
TOMGREEN11
TOM2WHITE-8
TOM2SILVER-4
TOM2GOLD0
TOM2GREY4

<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>
</tbody>

Again, any help is appreciated here.

Cheers,

Absent.
 
Upvote 0
Unfortunately I have bitten of more than I can chew with this.
Hopefully one of the Formula experts will step in & help.
 
Upvote 0
Not to worry.

This has quite a few of us stumped also. Was hoping I could somehow use a count formula to tell us what row each number is coming from and then use that as a reference for which code is assigned to each number, distinguishing between the dupes.

May just have to revert to using a mixture of VBA and excel formulae afterwards.
 
Upvote 0

Forum statistics

Threads
1,215,634
Messages
6,125,934
Members
449,275
Latest member
jacob_mcbride

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