Compare on a row

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

Got a long sheet with 3 columns with GTIN codes. These need to be compared to each other and when one is off I need the line to be red for example. So if A2, B2 and C2 are not the same I need to be able to see that. Is that possible to do?

Thank you for your time.

Romano
 
The original macro assumed that the data started in row 2 when it actually starts in row 4. Try:
VBA Code:
Sub CompareData()
    Application.ScreenUpdating = False
    Dim v As Variant, dic As Object, i As Long
    v = Range("E4", Range("E" & Rows.Count).End(xlUp)).Resize(, 3).Value
    Set dic = CreateObject("Scripting.Dictionary")
    For r = LBound(v) To UBound(v)
        For c = 1 To UBound(v, 2) - 1
            If v(r, c) <> v(r, c + 1) Then
                Range("E" & r + 3).Resize(, 3).Interior.ColorIndex = 3
                Exit For
            End If
        Next c
    Next r
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
The original macro assumed that the data started in row 2 when it actually starts in row 4. Try:
VBA Code:
Sub CompareData()
    Application.ScreenUpdating = False
    Dim v As Variant, dic As Object, i As Long
    v = Range("E4", Range("E" & Rows.Count).End(xlUp)).Resize(, 3).Value
    Set dic = CreateObject("Scripting.Dictionary")
    For r = LBound(v) To UBound(v)
        For c = 1 To UBound(v, 2) - 1
            If v(r, c) <> v(r, c + 1) Then
                Range("E" & r + 3).Resize(, 3).Interior.ColorIndex = 3
                Exit For
            End If
        Next c
    Next r
    Application.ScreenUpdating = True
End Sub
That definitely did the trick. Thank you for your help.
 
Upvote 0

Forum statistics

Threads
1,216,108
Messages
6,128,872
Members
449,475
Latest member
Parik11

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