jeudi 5 août 2021

vba having strange case with range.value equlas

In vba I have written code with IF statement and Range.Value expression for comparing values of two cells. It colors the font if they are different. It doesnot work on some cells, even the difference between cell values equals to zero. For what reason it can be? Any ideas? Noting that, with condiditional formatting duplicate cells with color, it works. But I want to know why it works for some cells, and not in others? Code is like;

For i=3 To 23
If Not ThisWorkbook.Sheets("sth").Cells(i,2).Value = ThisWorkbook.Sheets("sth").Cells(i,3).Value Then
ThisWorkbook.Sheets("sth").Cells(i,2).Font.Color=vbBlue
ThisWorkbook.Sheets("sth").Cells(i,3).Font.Color = vbBlue
End If
Next i

Aucun commentaire:

Enregistrer un commentaire