The code checks for duplicate in 16 named ranges and colors the duplicates in each range green and lets me know if any were found. With my limited knowledge of VBA I got this to work, but I bet there is a better way to do it, any thoughts
Code:
Sub CheckDups()
'checks for duplicate numbers
Dim Rng As Range
Dim Msg As String
Dim Dup As Integer
Dim CardRange As String
Dup = 0
For Each Rng In Range("Card1").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card1"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card2").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card2"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card3").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card3"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card4").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card4"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card5").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card5"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card6").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card6"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card7").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card7"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card8").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card8"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card9").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card9"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card10").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card10"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card11").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card11"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card12").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card12"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card13").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card13"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card14").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card14"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card15").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card15"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
For Each Rng In Range("Card16").Cells
If Application.WorksheetFunction.CountIf( _
Range("Card16"), Rng) > 1 Then
Rng.Interior.ColorIndex = 4 'Green
End If
Next Rng
CardRange = "Card1,Card2,Card3,Card4,Card5,Card6,Card7,Card8,Card9,Card10,Card11,Card12,Card13,Card14,Card15,Card16"
For Each Rng In Range(CardRange).Cells
If Rng.Interior.ColorIndex = 4 Then
Dup = 1
End If
Next Rng
If Dup = 1 Then
MsgBox "There Are Duplicate Numbers In The Cards, They Have Been Marked In Green" & vbLf & _
"Fix Them And Then Click On Reset Cards", , "Duplicates In Cards"
End If
End Sub