Basically, I want my code to go down through the values in a range and add to a dictionary only unique values. That is, only add the nth value if it has not been previously added. The result being a dictionary which keys are all the values from the range without duplicates. Here's my code:
Sub CreatePatientList()
Dim outputsh As Worksheet
Set outputsh = Workbooks(1).Sheets(1)
Dim recDict As New Scripting.Dictionary
Dim i As Variant, rowCount As Long
rowCount = outputsh.Cells(Rows.Count, 1).End(xlUp).Row
For Each i In Range("O2:O" & rowCount)
If recDict.Exists(i) Then
MsgBox ("Exists")
Else
recDict.Add i, i
End If
Next
Set recDict = Nothing
End Sub
Right now, 100% of the values in the range are being added to the dictionary.
Any help? Thanks in advance!!