mercredi 17 février 2021

Excel formula - How to conditionally fill a column with values from another table

I have 2 tables here:

enter image description here

I want to fill up the "Code" column in Table 1 by referring to Table 2. The condition for the value is that the Start date must be in between the ProductionDate and ExpiryDate of Table 2, and the Type in Table 1 must match the Type in Table 2, else return NA. I have come up with the formula for cell D4 =IFS(AND(C4>=H4,C4<=I4,B4=G4),F4,AND(C4>=H5,C4<=I5,B4=G5),F5,AND(C4>=H6,C4<=I6,B4=G6),F6).

Is there a simpler way to write the formula?

Aucun commentaire:

Enregistrer un commentaire