I have a spreadsheet that uses VBA to retrieve data from a database and copy it into a worksheet. I need to compare two columns to see if they match. The possible values are "TRUE", "FALSE", or a blank cell.
I have a simple formula to flag the row if the values are different: =IF(I2=J2,"Same","Difference")
This formula works fine if the values match, or if they are TRUE/Blank or TRUE/FALSE, but it does not evaluate as expected when there's a FALSE and a blank cell!

If I type in the word "FALSE" the formula evaluates properly (like in the image below). The formula only seems to be tripped up when the data is pasted from the database by VBA.
I suspect this has something to do with Excel treating FALSE and blank cells as both equivalent to "0", but I cannot figure out how to easily workaround this "feature." A couple things I tried:
- I confirmed the cell types are set to "Text" for all cells and I tried using VBA to force the format to be text by using
Range("I:J").NumberFormat = "@". Still evaluates to "Same." - I tried manually recalculating the formula by using the "Calculate Now" option in the Formulas ribbon. Still evaluates to "Same."
- I can write an ugly formula in the IF statement to check if the cells match:
=IF(OR(AND(I2="FALSE",J2="FALSE"), AND(I2="TRUE",J2="TRUE"), AND(I2="",J2="")),"Same","Difference")Is there a way to simplify this formula or force the I2=J2 formula to calculate correctly in case we ever have to handle data other than true/false/blank?



=IF(AND(A1=B1,LEN(A1)=LEN(B1)),"same","different")- cybernetic.nomadLEN(A1)=LEN(B1)sinceTRUEandFALSEdon't contain the same amount of letters. - riskypenguinTEXT(H11,"@")=TEXT(I11,"@")- Nathan_Sav