Forum Discussion
If Function
To add to what Detlef said, just to make sure your 2 cells have same value, use LEN to get the number of characters in your cells.
See example below. Visually, A2 and B2 are same, but A2 has a space character in the end.
=IF(A2 = B2,TRUE,FALSE) | |
a | a |
=LEN(A2) | =LEN(B2) |
LEN formula in A3 will show 2 in this case, while B3 will show 1, so definitely these cells are not identical.
FALSE | |
a | a |
2 | 1 |
Removing the space char from A2, IF formula evaluates correctly.
TRUE | |
a | a |
1 | 1 |
Also, you can use TRIM inside your IF formula, this will remove leading and trailing spaces from your referenced cell.
=IF(TRIM(A2) = TRIM(B2),TRUE,FALSE) | |
a | a |
=LEN(A2) | =LEN(B2) |
Here is the result; even if I have that trailing space in A2, TRIM will take care of it.
TRUE | |
a | a |
2 | 1 |
Before relying on TRIM 100%, I would recommend reading this article to know what TRIM removes and what it doesn't remove.
https://support.office.com/en-us/article/trim-function-410388fa-c5df-49c6-b16c-9e5630b479f9