Excel, if Excel cell is X, Y or Z then display 1,

2019-08-24 04:25发布

问题:

I need help with code for excel.

What I need is if a cell contains "Achieved" then display 1, "Partially Achieved" display 2 and if "Not Achieved" display 3.

Can someone help with what I need to enter?

Thanks

回答1:

=IF(A1="Achieved",1,IF(A1="Partially Achieved",2,IF(A1="Not Achieved",3,"NA")))



回答2:

Try,

=iferror(match(A1, {"Achieved", "Partially Achieved", "Not Achieved"}, 0), "")

fwiw, to perform the reverse (with 1, 2 or 3 in a cell) use,

=iferror(choose(A1, "Achieved", "Partially Achieved", "Not Achieved"), "")


回答3:

=SWITCH(A1,"Achieved",1,"Partially Achieved",2,"Not Achieved",3)

Where A1 is the cell you want to check of course.



回答4:

For those without SWITCH (and half the length):

=MATCH(LEFT(A1),{"A","P","N"},0)