I found this solution for my problem. And it works fine like this:
Dim CNPJs As New Collection, a
Dim i As Long
Dim rng As Range
U_L = Plan2.Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
For Each rng In Plan2.Range("A2:A" & U_L)
CNPJs.Add rng.value, rng.value
Next
But now I want to bulid a function that returns this unique array, because I will use this many times... I tried this:
Public Function unArray(myRange As Range) As Collection
Dim arr As Collection, a
On Error Resume Next
For Each rng In myRange
arr.Add rng.value, rng.value
Next
unArray = arr
End Function
And I call it:
Sub test()
Dim CNPJs As New Collection, a
U_L = Plan2.Range("A" & Rows.Count).End(xlUp).Row
CNPJs = unArray(Plan2.Range("A2:A" & U_L))
End Sub
But it returns this error:
"Compilation error:"
"The argument is required"
Can you help me?