Hello,
Can someone help with the below code?
This is a macro that finds duplicates based on three criteria.
Is it possible to add another criteria but not duplicate but a difference. I need a code to find the same account number (criteria 1), the same amount (criteria 2), the same value date (criteria 3) and 4th criteria: information in first duplicate is different from information in corresponding duplicate.
The information in 4th criteria column is always "0" or "1". To solve the problem, the two items should have all the above 3 criteria the same, and one item "0" and the other "1". If both have "0" or "1" macro should not find it.
this is the code
Thank you in advance
Tommeck37
Can someone help with the below code?
This is a macro that finds duplicates based on three criteria.
Is it possible to add another criteria but not duplicate but a difference. I need a code to find the same account number (criteria 1), the same amount (criteria 2), the same value date (criteria 3) and 4th criteria: information in first duplicate is different from information in corresponding duplicate.
The information in 4th criteria column is always "0" or "1". To solve the problem, the two items should have all the above 3 criteria the same, and one item "0" and the other "1". If both have "0" or "1" macro should not find it.
this is the code
Code:
Sub MatchingItems()Dim LastRow As Long, DatesCol As Long, AmountsCol As Long, NostroCol As Long
LastRow = Sheets(1).Range("E" & Sheets(1).Rows.Count).End(xlUp).Row
DatesCol = 6 'D column with dates
AmountsCol = 5 'E column with amounts
NostroCol = 1 ' A column with account number
'Columns(DatesCol).Interior.ColorIndex = xlNone 'dates lose color
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets(1).Activate
With Sheets(1)
For i = 1 To LastRow 'for each row
If 2 <= Application.WorksheetFunction.CountIfs(Range(Cells(1, DatesCol), Cells(LastRow, DatesCol)), _
Cells(i, DatesCol), _
Range(Cells(1, AmountsCol), Cells(LastRow, AmountsCol)), _
Cells(i, AmountsCol), _
Range(Cells(1, NostroCol), Cells(LastRow, NostroCol)), _
Cells(i, NostroCol)) _
Then Cells(i, 5).Interior.ColorIndex = 3 ' 'counts the date values associated with occurrences if there's more than one then the date gets a nice background color
Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
MsgBox ("Matching Items Put In Red")
End Sub
Thank you in advance
Tommeck37