3

Assuming Cell A1 contains 2 (as a number) and Cell B1 contains „<=5“ (as a string), how can I check in cell C1 if 2 is smaller or equal than 5, as =A1&B1 returns „2<=5“ (as a string) and =evaluate(A1&B1) returns an error (#value)?

As the operation might change depending on cell content (for example < instead of <= or also > or >=) I can’t simply extract the number from cell B1 and use it (or I would have to manually check additionally which operation is used and also prepare something like a switch operation)

The excel version is a non-M365 version (Excel 2021).

1
  • Great answer below... Do you need a Boolean result, or would zero/non-zero serve as well? Trivially simpler =COUNTIF(A1, B1) may do the job.
    – Fe2O3
    Commented 10 hours ago

1 Answer 1

8

You can do =COUNTIF(A1, B1)

Or if you want to return True or False do: =IF(COUNTIF(A1, B1) = 1, TRUE, FALSE)

Or as suggested by FlexYourData: =COUNTIF(A1, B1)=1 , even shorter, this will also return TRUE or FALSE

1
  • 1
    The second expression can be written as =COUNTIF(A1, B1)=1 Commented 18 hours ago

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.