问题
One table has policy numbers and the agent who wrote each policy. An agent's name multiple times.
Another table has just the policy numbers and I want to add the agents' names next to the numbers.
VLOOKUP doesn't work because the firs table shows the agents' names multiple times.
Any ideas how to do this?
回答1:
If the numbers are unique and only the Agents are duplicates, you can use Index/Match or Vlookup.
With Index / Match:
=IFERROR(INDEX(Policy!$B$2:$B$15,MATCH(A2,Policy!$A$2:$A$15,0)),"")
Policy is the sheet where you have Numbers (Column A, A2:A5)and corresponding Agent (Column B, B2:B15) change the references to correspond the last row but keep $ for fixed references. You can drag it down next to A2 where the numbers that you need to find their Agent are.
With Vlookup:
=IFERROR(VLOOKUP(A2,Policy!$A$2:$B$15,2,FALSE),"")
You can drag it down, next to A2 where the numbers are in the new sheet.
Also change Policy!$A$2:$B$15 to correspond the references of your Data.
2 to return the value from the second column (Agent)
False for exact match.
来源:https://stackoverflow.com/questions/44850530/match-values-from-two-tables-in-excel