Given the following code…
If [a2].Value = [b2].Value Then [c2] = "yes" Else [c2] = "NO !!!" End If
On the spreadsheet, both A2 and B2 display AA-100
The value of B2 is also “AA-100”. However, the value that is typed into A2 is actually “100” since it’s formatted using the Custom field for a cell, using this format…
I thought the .Value was supposed to extract what the user sees, but it turns, out that’s not the case.
The .Value is what you would see in the formula bar. If you want what is displayed in the cell with a custom number format, use the .Text property.
If [a2].Text = [b2].Text Then ...
Note that the .Text property picks up the cell’s value as it is displayed in the cell so using left indentation will also add leading space(s). It isn’t the most reliable method of direct comparison.