Hi,
I have a datasheet with product codes and product names. I'm trying to create a macro that highlights any instance when two rows have the same product code but different product names. I have a formula which isn't working and I suspect it's because I'm using the <> which I presume is designed for numbers rather than strings.
Here is my code
Is there anyway for VBA to identify if the text within two cells is not the same? Thanks!
I have a datasheet with product codes and product names. I'm trying to create a macro that highlights any instance when two rows have the same product code but different product names. I have a formula which isn't working and I suspect it's because I'm using the <> which I presume is designed for numbers rather than strings.
Here is my code
Code:
Sub product_code()
If Range("U" & i) = Range("U" & i + 1) And Range("V" & i) <> Range("V" & i + 1) Then
Range("A" & i & ":AD" & i).Interior.ColorIndex = 3
End If
If Range("U" & i) = Range("U" & i - 1) And Range("V" & i) <> Range("V" & i - 1) Then
Range("A" & i & ":AD" & i).Interior.ColorIndex = 3
End If
End Sub
Is there anyway for VBA to identify if the text within two cells is not the same? Thanks!