Frage

I have 2 spread sheets

On sheet 1 I have 2 columns (Prop_id and Code) sheet 2 I have 2 columns (prop_id and Store)

I need to match Prop_id in sheet 2 with Prop_id in sheet 1 which have some duplicate id, and then return value from code based on a condition,

If code=Ma type Ma in Store column in sheet 2

If code=CP type CP in Store Column in sheet 2

Many thanks

War es hilfreich?

Lösung

I suggest you use IF and COUNTIFS like follows:

Sheet1 is above, Sheet2 is below:

enter image description here

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:

  1. The column A of Sheet1 (Sheet1!$A:$A) needs to be equal to A2 (the Prop_id)

  2. The column B of Sheet1 (Sheet1!$B:$B) needs to be equal to MA.

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top