How can Duplicate rows in a range be compared and higlighted?

Andybooth

New Member
Joined
Jun 12, 2013
Messages
1
I am trying to step down row by row through a range and compare the current row against all the other rows in a range before and after the current row.
If a possible duplicate is found where 8 of 9 columns in the row are a duplicate of other rows I want to highlight the rows for investigation.
I have tried to do this with code, but I am limited in that I am only able to step down through a column and compare the cells for duplicates
and then highlight them. This code I have attached below.
I also incude an example of the data I am comparing and two rows higlighted were duplicates have been found with the only difference being found is the REFNO which I expect, as I am trying to compare the underlying transaction details.
Can anyone assist me with this as I am stuck on how to store the row for comparison and then go through each of the other rows and compare against the current row.
Thanks
Andy


Code:
Sub FindDups()
    ScreenUpdating = False
   FirstItem = ActiveCell.Value
   SecondItem = ActiveCell.Offset(1, 0).Value
   Offsetcount = 1
   Do While ActiveCell <> ""
      If FirstItem = SecondItem Then
        ActiveCell.Offset(Offsetcount, 0).Interior.Color = RGB(255, 0, 0)
        Offsetcount = Offsetcount + 1
        SecondItem = ActiveCell.Offset(Offsetcount, 0).Value
      Else
        ActiveCell.Offset(Offsetcount, 0).Select
        FirstItem = ActiveCell.Value
        SecondItem = ActiveCell.Offset(1, 0).Value
        Offsetcount = 1
      End If
   Loop
   ScreenUpdating = True
End Sub

REFNOPRODUCTTYPEBuyerCCYAMOUNTInterest rateTransaction DATEDeliveryDate
123456XXXXTMEEUR1,233.58.0000000006 Jun 201307 Jun 2013
123457XXXXTUSEUR1,523.35.0700000006 Jun 201307-Aug-13
123897XXXXTUSUSD894,564.25.0700000006 Jun 201315-Oct-13
123576XXXXTMEEUR1,233.58.0000000006 Jun 201307 Jun 2013
124987XXXXO <st1:stockticker>GBP</st1:stockticker> 18,711.00.3000000006 Jun 201330-Sep-13
156912XXXXOWEUSD-184,768.47.1500000006 Jun 201307 Jun 2013

<COLGROUP><COL style="WIDTH: 32pt; mso-width-source: userset; mso-width-alt: 1572" width=43><COL style="WIDTH: 41pt; mso-width-source: userset; mso-width-alt: 2011" width=55><COL style="WIDTH: 25pt; mso-width-source: userset; mso-width-alt: 1206" width=33><COL style="WIDTH: 27pt; mso-width-source: userset; mso-width-alt: 1316" width=36><COL style="WIDTH: 22pt; mso-width-source: userset; mso-width-alt: 1060" width=29><COL style="WIDTH: 49pt; mso-width-source: userset; mso-width-alt: 2377" span=2 width=65><COL style="WIDTH: 71pt; mso-width-source: userset; mso-width-alt: 3474" width=95><COL style="WIDTH: 51pt; mso-width-source: userset; mso-width-alt: 2486" width=68><TBODY>
</TBODY>
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

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