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.
If one day you need to include a third condition, try like this:
It will work without
Exact()
. As noted in the comments,If()
is also not needed.