Highlight Non-indentical Text

Barklie

Board Regular
Joined
Jul 4, 2013
Messages
86
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

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!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,275
Messages
6,171,127
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top