Question

I'm trying to compare the first character in two different cells. If they both equal 9 than I want it to say TRUE, otherwise false.

I have the most terrible version of that written below. Can someone help me write this correctly?

=IF(AND(MID(B2,1,1))="9",(MID(C2,1,1))="9",TRUE,FALSE))

B2 and C2 are zip codes. I just want to see if they start with a 9 which shows they're in the same area but the exact cells don't match so I can't do a straight comparison of the entire cell. i.e. 94021 and 94111 would be TRUE since they both start with 9

Was it helpful?

Solution

You can use something like this

=IF(AND(LEFT(A1,1)="9", LEFT(B1,1)="9"), TRUE,FALSE)

No need to use MID, LEFTwill give you N first characters. Also AND combines logical conditions you can pass to IF

OTHER TIPS

What about

=IF(left(B2,1) = Left(C2,1))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top