Hi all,
I'm running into a logic mental block on something I'm working on.
I am trying to do 2 things:
1. Highlight any duplicates in column B (starting from row 3)
2. For each 'set' of duplicates in column B, check if column E has any duplicate values (different values to column B)
eg, column B value is "1" and is duplicated elsewhere in column B -> highlight duplicate values in Column E but only if column B =1. Rinse and repeat for other duplicates in column B.
Any help will be greatly appreciated.
I'm running into a logic mental block on something I'm working on.
I am trying to do 2 things:
1. Highlight any duplicates in column B (starting from row 3)
2. For each 'set' of duplicates in column B, check if column E has any duplicate values (different values to column B)
eg, column B value is "1" and is duplicated elsewhere in column B -> highlight duplicate values in Column E but only if column B =1. Rinse and repeat for other duplicates in column B.
Any help will be greatly appreciated.
VBA Code:
Sub HighlightDuplicates()
'Declare All Variables
Dim r As Range, rB As Range
Dim ws As Worksheet
Dim i As Long
'Clear previous highlighting
Worksheets("ProjectData").Cells.Interior.Pattern = xlNone
'Set target worksheet
Set ws = ThisWorkbook.Sheets("ProjectData")
'Find dupliates in coumn B and highlight amber
i = ws.Range("B" & Rows.Count).End(xlUp).Row
Set rB = ws.Range("B3:B" & i)
For Each r In rB
If WorksheetFunction.CountIf(rB, r.Value) > 1 Then
r.Interior.ColorIndex = 44
End If
Next
'For each row set of duplicates in column B, check column E for duplicates and highlight red (ColorIndex =3)
End Sub