Need help with nested if statements using match

tonyg88

New Member
Joined
Jan 18, 2015
Messages
12
Hi All,

Struggling with an excel problem. I have one list (list 1) with IDs and a corresponding value (letter).

Separately, i have a list of IDs (list 2) that I want to put the latest value for (see output columns for what i mean). I want to check first if a 2 -C exists, if not, check if a 2-B exists, whichever is the latest, display that value for the '2' ID.

Here's how i tackled it in excel:
  1. created a column for concatenated values for list 1
  2. Wrote nested if statement in output column of list 2
  3. nested if statement:
    1. =IF(MATCH(CONCATENATE(D1,", ","C"),C;C,0),"C",
    2. IF(MATCH(CONCATENATE(D1,", ","B"),C;C,0),"B",
      IF(MATCH(CONCATENATE(D1,", ","A"),C:C,0),"A",0)))


      Error: the formula returns a #N/A value

Note - I simplified the below example for readability, the real problem has more complicated IDs and the letter column has more characters.

List 1:

[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 230"]
<tbody>[TR]
[TD="class: xl65, width: 230"]ID[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]Letter [/TD]
[TD][TABLE="width: 230"]
<tbody>[TR]
[TD="class: xl65, width: 230"]concatenate (Column C)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]1, A[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]B[/TD]
[TD]1, B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]C[/TD]
[TD]1, C[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]A[/TD]
[TD]2, A[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]A[/TD]
[TD]2, A[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]2, B[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]2, B[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[TD]2, B[/TD]
[/TR]
</tbody>[/TABLE]

List 2:

[TABLE="width: 500"]
<tbody>[TR]
[TD]ID (column D)[/TD]
[TD]Output[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]B[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi,

Does this do what you need, if it does, your Column C is Not needed:


Book1
ABCDE
1List 1:List 2:
2
3IDLetterconcatenate (Column C)ID (column D)Output
41A1, A1C
51B1, B1C
61C1, C2B
72A2, A2B
82A2, A
911B2, B
102B2, B
112B2, B
12
13^^ Not needed
Sheet401
Cell Formulas
RangeFormula
E4=LOOKUP(2,1/FIND(" "&D4&" "," "&A$4:A$11&" "),B$4:B$11)


Formula copied down.
 
Upvote 0
thanks! seems to work, but confused how it works. What is the purpose of the "2,1" in the lookup function? also, what is the purpose of the "" and & symbols?

Also, the original list is a lot longer and has more IDs / letters, do you think the formula would still apply?
 
Last edited:
Upvote 0
We're looking up the Value of 2 within the FIND results divided by 1 (which will Never be greater than 1), so the LOOKUP will return the Last found Value (which is what you want).
The SPACE " " in front and behind the Lookup Value and Lookup Array prevents Errors for the Lookup, see my sample Row # 9, which is 11 (eleven), Not 1 (One), without the SPACES, the LOOKUP will return the incorrect result of "B".

Don't see your actual data, can not answer definitively, but it should work.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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