Excel: if cell 1 contains X or Y or Z, then cell 2 should equal W

前端 未结 2 381
天命终不由人
天命终不由人 2021-01-07 11:46

As from the title, I need Excel to auto-populate the B row cells based on the corresponding A row cells content.

So if cell A1 contains X or Y or Z, th

相关标签:
2条回答
  • 2021-01-07 12:11

    If the comparative values are to be hard-coded into the formula, it can be tightened up like this.

    =IF(OR(A1={"X","Y","Z"}), "W", IF(OR(A1={"G","H","I"}), "K", ""))
    
    0 讨论(0)
  • 2021-01-07 12:27

    You can try adding this formula to B1:

    =IF(OR(A1="X";A1="Y";A1="Z");"W";IF(OR(A1="G";A1="H";A1="J");"W";""))
    

    The first part checks if A1 is either X Y or Z. If it's true, it returns "W", if it's false, it will call for another IF statement, that checks if A1 is in G H or J. If it's true, yes, "W" again, if it's not, it'll just put nothing in there.

    It's possible to simplify it, by using only one IF/OR like this:

    =IF(OR(A1="X";A1="Y";A1="Z";A1="G";A1="H";A1="J");"W";"")
    

    You might have to replace ; with , depending on your locale settings.

    0 讨论(0)
提交回复
热议问题