A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
John Doe
vs
John Doe (note the 2 extra spaces between the first and last name)
Okay, this one is easy... just use apply the WorksheetFunction.Trim function to each string to squeeze out the extra spaces (assuming they are pure spaces and not ASCII 160 characters... the non-breaking space websites use). So...
If WorksheetFunction.Trim(Range("A1").Value) = WorksheetFunction.Trim(Range("B1").Value) Then
If the spaces could be ASCII 160 characters, then use the VBA Replace function to get rid of them...
If WorksheetFunction.Trim(Replace(Range("A1").Value, Chr(160), " ")) = WorksheetFunction.Trim(Replace(Range("B1").Value, Chr(160), " ")) Then
John Do
vs
Jon Do
This is a little harder problem because of the sheer number of variations possible depending on the text involved. In this case, perhaps a SoundEx function might be useful. See this link for more details...
http://www.j-walk.com/ss/excel/tips/tip77.htm
You can combine function calls to the SoundEx function with the WorksheetFunction.Trim and Replace codes I showed above.
In this specific case, I have a 10 digit number
010-482-21
for some reason in comparing that to another, which appears exactly the same, the IF function fails, and returns a false.
=IF(a1=b1,"ok", b1)
a1 = 010-482-21
b1 = 010-482-21 (with some indeterminable difference from the contents of a1)
I don't know what it is, but it returns a false. I've checked the data type, the spacing of blanks in the cell, verified that the digits, and cell's contents actually match, and nothing that I've done can find it.
In this specific case, and without being able to see your actual worksheet, I would check to make sure all the things that look like zeroes are, in fact, zeroes and not the upper case letter "O". And I would check to make sure all the ones are, in fact, the number one and not the lower case case letter "L". There is also the possibility that you have a trailing blank space or trailing ASCII 160 character attached to one of those values, but my first suggestion above should take care of that problem.
NOTE: Please mark the message or messages (yes, you can mark more than one) that answer your question as the "Answer" so that others will know your question has been resolved.