Lookup that returns only one of multiple matches based on 2-criteria

kevsvette

New Member
Joined
Oct 5, 2015
Messages
24
I need a look up formula (in Col. Q) that matches an “Account Name” in column AE with the corresponding “Account Name” in column N only if the “Type” in column Y matches a given value (in this case “Illustration”) & only return the associated # from column O for the first match. It will always start in row 4.

Any additional matches return “--“, so I can use a sort to drop them to bottom.

Also, any entries that do not match return an “Error”.

The table below would be before a sort which brings to the top only those entries that match with a given #.

Col. NCol. OCol. QCol. YCol. AE
Row 4Smith, Bob11IllustrationSmith, Bob
Row 5Smith, Janet2--IllustrationSmith, Bob
Row 6Jones, Mary33IllustrationJones, Mary
Row 7Stewart, Tony4ErrorMeetingJones, Mary
Row 8Petty, Richard5--IllustrationJones, Mary

Right now I use a simple vlookup to find the matches & resort the table but get all the entries that returns the #, & have too many duplicate entries to deal with.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Book1
NOQYAE
4Smith, Bob11IllustrationSmith, Bob
5Smith, Janet2--IllustrationSmith, Bob
6Jones, Mary33IllustrationJones, Mary
7Stewart, Tony4ErrorMeetingJones, Mary
8Petty, Richard5--IllustrationJones, Mary
Sheet1
Cell Formulas
RangeFormula
Q4=IF($Y4 = "Illustration", IF(COUNTIFS($AE$4:$AE4,$AE4,$Y$4:$Y4,"Illustration") > 1, "--", VLOOKUP($AE4, $N$4:$O$8, 2, FALSE)), "Error")


Is this along the right lines? You'll need to change $N$4:$O$8 to include the whole lookup range. "Illustration" is also hard-coded here; not sure if that matters.

WBD
 
Upvote 0
This is close, but the Vlookup is returning #N/A when the name isn't on the lookup list. Also, I'm not sure if it matters, but the name column AE is not in alphabetical order. I can do so, but I think that might be a problem. I think having a static reference would correct it. When I get more of a chance to play with it I'll post a reply...

Thanks for you help!
 
Upvote 0
This is close, but the Vlookup is returning #N/A when the name isn't on the lookup list. Also, I'm not sure if it matters, but the name column AE is not in alphabetical order. I can do so, but I think that might be a problem. I think having a static reference would correct it. When I get more of a chance to play with it I'll post a reply...

Thanks for you help!

What should be the desired results in column Q?
 
Upvote 0
Thanks for the input Wideboydixon, your formula gave me the ideas needed to tweak the formula. Below is what I was able to do to get the desired result...

=IF(COUNTIF(N:N,AE4)0,IF($Y4="Illustration",IF(COUNTIFS($AE3:$AE4,$AE4,$Y3:$Y4,"Illustration")1,"--",VLOOKUP(AE4,$N$3:$O$312,2,FALSE)),"Matching Name, Err Type"),"No Name Match")

This is an attempt to match up only the 1st instance of a match, by name, from 2 different tables if the type in one of the 2 tables is listed as "illustration" & identify any additional duplicate matches that can be sorted out.

1st the COUNTIF checks to make sure that the Name in column AE (table 2) is even in column N (table 1). If so it continues to check if the Type is Illustration (both in table 2) as well as determines whether or not it’s the 1st instances of the name matching with a type of Illustration. If its the 1st instance, the VLOOKUP will give me the corresponding # that's in table 1 so I can resort table 2 to match up with table 1.

Along the way if the table 2 name doesn't match up with a table 1 name than it returns a No Name Match. If the Name matches but the Type isn't Illustration, than it returns Matching Name, Err Type. If the Name matches & the Type is illustration & it’s a duplicate matched entry, than it returns an "--".

Before I put in the formulas I need to sort table 2 by the Name and I further sort to get the associated Illustration record entries to the top (via cell shading). So far I've tested it & it works out fine, but I won’t give it its final test until Thursday. I'll let everyone know if it’s truly successful or not, but so far so good.

Once table 2 is sorted as above & the formulas are in place (col. Q) I resort based on column Q. Unfortunately there are name spelling differences & not always will there be a Type of Illustration for a given table 1 name thou there is a table 2 match, but that's the way it goes.

Thanks for everyone's consideration!
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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