You can use something like this
=IF(AND(LEFT(A1,1)="9", LEFT(B1,1)="9"), TRUE,FALSE)
No need to use MID
, LEFT
will give you N first characters. Also AND
combines logical conditions you can pass to IF
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
Solution
You can use something like this
=IF(AND(LEFT(A1,1)="9", LEFT(B1,1)="9"), TRUE,FALSE)
No need to use MID
, LEFT
will 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))