I am trying to loop through my worksheet to count any duplicates. UniqueId is a collection of ranges.
Dim uniqueId As New Collection
For i = 1 To numSets
Dim rng As Range
'Find Unique Id Range
Set rng = Application.InputBox(("In Data Set " & i & ", please select range of the unique identifier. (Do not include header)"), "Obtain Unique ID Column", Type:=8)
uniqueId.Add rng
Next
For i = 1 To numSets
For j = 2 To lastcell
If (Application.WorksheetFunction.CountIf(Range(uniqueId(i).Address), Cells(j, 1).Value) > 1) Then
If (Cells(j, numSets * numVar + numVar + 3).Value <> "") Then
Cells(j, numSets * numVar + numVar + 3).Value = Cells(j, numSets * numVar + numVar + 3).Value & ", Review- this is a duplicate in Data Set " & i
Else
Cells(j, numSets * numVar + numVar + 3).Value = "Review- this is a duplicate in Data Set " & i
End If
End If
Next
Next
The count if is not working because it should have duplicates but it never does. I think the problem may come down to Range(uniqueId(i).Address) but I am not sure.