Have a cell which will either have W, L or BB in it. I want to add the cell in O6 if the N6 cell contains any of the strings mentioned below what is the code for this?

below is what I currently have thought it to be.


To get the value in cell O6 if cell N6 equals "W", "L" or "BB", and get zero if cell N6 does not equal one of those values, try this:

=O6 * regexmatch(N6, "^(W|L|BB)$")

The regexmatch() function will return a true/false value, but it gets automatically coerced into 1/0 when an arithmetic operator like * is applied.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.