Hi all,
I'm currently trying to get my head around avoiding copying and pasting the same code, but looking into functions and sub routines, as got me a bit baffled.
Would anyone be able to help show me how I could avoid repeating myself in the example code below. Three different ranges that get duplicates highlighted.
Much Appreciated,
Berian
I'm currently trying to get my head around avoiding copying and pasting the same code, but looking into functions and sub routines, as got me a bit baffled.
Would anyone be able to help show me how I could avoid repeating myself in the example code below. Three different ranges that get duplicates highlighted.
VBA Code:
Sub HightlightDuplicates()
Dim Rng As Range
Dim Unq As UniqueValues
Set Rng = MasterStock.Range("A3:A50000")
Set Unq = Rng.FormatConditions.AddUniqueValues
Unq.DupeUnique = xlDuplicate
Unq.Interior.Color = 13551615
Unq.Font.Color = RGB(156, 0, 6)
Set Rng = MasterStock.Range("F3:F50000")
Set Unq = Rng.FormatConditions.AddUniqueValues
Unq.DupeUnique = xlDuplicate
Unq.Interior.Color = 13551615
Unq.Font.Color = RGB(156, 0, 6)
Set Rng = MasterStock.Range("AD3:AD50000")
Set Unq = Rng.FormatConditions.AddUniqueValues
Unq.DupeUnique = xlDuplicate
Unq.Interior.Color = 13551615
Unq.Font.Color = RGB(156, 0, 6)
End Sub
Much Appreciated,
Berian