MeeroMan
MeeroMan

Reputation: 1

IF - ELSE statement Google Sheets various values

If a cell was "x","y", or "z", I would like to spit out XYZ

Else "a", "b", or "c", then ABC

ELSE

assign "MNO"

I am currently working with this:

=IF(ISERROR(FIND("x",A2)), IF(ISERROR(FIND("a",A2)), "ABC", "MNO"),"XYZ")

Upvotes: 0

Views: 109

Answers (2)

player0
player0

Reputation: 1

try:

=IF(REGEXMATCH(A2, "x|y|z"), "XYZ", 
 IF(REGEXMATCH(A2, "a|b|c"), "ABC", "MNO"))

0


if A2 is number use:

=IF(REGEXMATCH(A2&"", "1|2|3"), "XYZ", 
 IF(REGEXMATCH(A2&"", "a|b|c"), "ABC", "MNO"))

for arrayformula use:

=ARRAYFORMULA(IF(A2:A="",,
 IF(REGEXMATCH(A2:A, "x|y|z"), "XYZ", 
 IF(REGEXMATCH(A2:A, "a|b|c"), "ABC", "MNO"))))

Upvotes: 2

Scott Craner
Scott Craner

Reputation: 152475

Use OR:

=ArrayFormula(IF(OR(A2={"x","y","z"}),"XYZ",IF(OR(A2={"a","b","c"}),"ABC","MNO")))

enter image description here

Upvotes: 2

Related Questions