Hi All
I have a workbook with multiple tabs, I need to find out duplicate rows in the sheets One to Five if the cells in columns B, D and F on the rows are the same. Duplicate rows should be highlighted for manual deletion.
I have searched some code below, however they are compared from column A to F but indeed only B, D and F are required to compare only. Anyway they don't work probably.
Please could any one help. Many thanks.
I have a workbook with multiple tabs, I need to find out duplicate rows in the sheets One to Five if the cells in columns B, D and F on the rows are the same. Duplicate rows should be highlighted for manual deletion.
I have searched some code below, however they are compared from column A to F but indeed only B, D and F are required to compare only. Anyway they don't work probably.
Please could any one help. Many thanks.
VBA Code:
Sub Find_Duplicate_Rows()
Dim arrSheets As Variant, sh As Variant, LRow As Long, i As Variant, r As Long
arrSheets = Array("One", "Two", "Three", "Four", "Five")
LRow = sh.Cells(Rows.Count, "A").End(xlUp).Row
For Each sh In arrSheets
Dim cRange As Range
Dim cSearch As Range
Dim acSearch As String
Dim cDuplicate As String
Dim x As Integer
Dim name As String
Range("A2:F" & LRow).Interior.Pattern = xlNone
cColor = 6
Set cRange = Range("A2:F" & LRow)
For Each i In cRange
x = WorksheetFunction.CountIf(Columns(2), i) - 1
If x > 0 Then
cDuplicate = i & i.Offset(0, 1).Value & i.Offset(0, -1).Value
Set cSearch = i
For x = 1 To x
Set cSearch = cRange.Find(What:=i, After:=cSearch, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
acSearch = cSearch.Address
If cDuplicate = Range(acSearch).Value & Range(acSearch).Offset(0, 1).Value & Range(acSearch).Offset(0, -1).Value Then
With Union(Range(acSearch), Range(acSearch).Offset(0, 1), Range(acSearch).Offset(0, -1), i, i.Offset(0, 1), i.Offset(0, -1)).Interior
.ColorIndex = cColor
End With
End If
Next x
End If
cColor = cColor + 1
Next i
Next sh
End Sub