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

て烟熏妆下的殇ゞ 提交于 2020-01-16 08:36:09

问题


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)


来源:https://stackoverflow.com/questions/50661046/excel-if-excel-cell-is-x-y-or-z-then-display-1-2-or-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!