I suggest you use IF
and COUNTIFS
like follows:
Sheet1 is above, Sheet2 is below:
The formula in Sheet2 cell B2 is:
=IF(COUNTIFS(Sheet1!$A:$A,$A2,Sheet1!$B:$B,"MA")>0,"MA","")
And that in cell C2 is:
=IF(COUNTIFS(Sheet1!$A:$A,$A2,Sheet1!$B:$B,"CP")>0,"CP","")
Details:
COUNTIFS
counts the number of rows that satisfy certain conditions. The conditions I applied are:
The column A of Sheet1 (
Sheet1!$A:$A
) needs to be equal to A2 (theProp_id
)The column B of Sheet1 (
Sheet1!$B:$B
) needs to be equal toMA
.
If there are more than 0 rows that satisfy the condition, then that means that the Prop_id with Code MA
exists and tells Excel to put MA
.
The same logic goes for CP
.