Using the following formula
=INDEX($A$2:$B$6,MATCH($D2,$B$2:$B$6,0),1)
To create colD with matching item_ids from the model_num in colC. The problem is when it doesn’t find a matching model_num in colC then it puts #N/A in colD.
item_id (colA) model_num (colB) data (colC) new_data (colD)
-------- ---------- ------- ----------
870834 FD021 FD1424B 10752514
16595156 S3TA03B Not Required #N/A
10752514 FD1424B S3TA03B 16595156
10756167 SU03B Included with Kit #N/A
14667130 KDAD SU03B 10756167
If it doesn’t find a match it should just copy what is already in colC to colD.
item_id (colA) model_num (colB) data (colC) new_data (colD)
-------- ---------- ------- ----------
870834 FD021 FD1424B 10752514
16595156 S3TA03B Not Required Not Required
10752514 FD1424B S3TA03B 16595156
10756167 SU03B Included with Kit Included with Kit
14667130 KDAD SU03B 10756167
The Question
When the formula doesn’t find a match in colC how can I tell it to just copy the contents of colC to colD?
Your formula doesn’t work, I assume you need a MATCH function in there….also I assume the lookup value should be C2 as the formula goes in D2 – like this
=INDEX($A$2:$B$6,MATCH($C2,$B$2:$B$6,0),1)Which version of Excel are you using? In Excel 2007 or later you can use IFERROR to get what you want, i.e. this version in D2 copied down
=IFERROR(INDEX($A$2:$B$6,MATCH($C2,$B$2:$B$6,0),1),$C2)…or in any version
=IF(ISNA(MATCH($C2,$B$2:$B$6,0)),$C2,INDEX($A$2:$B$6,MATCH($C2,$B$2:$B$6,0),1))