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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,756
Messages
6,132,536
Members
449,735
Latest member
Gary_M

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