Is OR function in Excel validations broken?

71 views Asked by At

I'm trying to write a custom validation function in Excel that assures that the text in a cell starts with http:// or https://. If I use the formula

=EXACT(LEFT(INDIRECT("Z"&ROW()), 8), "https://")

the validation works but only checks for https://. If I add an OR like this

=OR(EXACT(LEFT(INDIRECT("Z"&ROW()), 8), "https://"), EXACT(LEFT(INDIRECT("Z"&ROW()), 7), "http://"))

it does not work; it always evaluates to false. I then tried the following just to test the OR function:

=OR(EXACT(LEFT(INDIRECT("Z"&ROW()), 8), "https://"), TRUE)

and this also evaluates to FALSE! Am I crazy or is the OR function broken? I found that when pasting this equation in a cell it works just fine. It only doesn't work when it's used as a custom validation function.

1

There are 1 answers

4
Vityata On

If one day you need to include a third condition, try like this:

=OR(LEFT(D1,8)="https://",
    LEFT(D1,7)="http://")

It will work without Exact(). As noted in the comments, If() is also not needed.