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
<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>
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
REFNO | PRODUCT | TYPE | Buyer | CCY | AMOUNT | Interest rate | Transaction DATE | DeliveryDate |
123456 | XXXX | T | ME | EUR | 1,233.58 | .00000000 | 06 Jun 2013 | 07 Jun 2013 |
123457 | XXXX | T | US | EUR | 1,523.35 | .07000000 | 06 Jun 2013 | 07-Aug-13 |
123897 | XXXX | T | US | USD | 894,564.25 | .07000000 | 06 Jun 2013 | 15-Oct-13 |
123576 | XXXX | T | ME | EUR | 1,233.58 | .00000000 | 06 Jun 2013 | 07 Jun 2013 |
124987 | XXXX | O | <st1:stockticker>GBP</st1:stockticker> | 18,711.00 | .30000000 | 06 Jun 2013 | 30-Sep-13 | |
156912 | XXXX | O | WE | USD | -184,768.47 | .15000000 | 06 Jun 2013 | 07 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>