john316swan
Board Regular
- Joined
- Oct 13, 2016
- Messages
- 66
- Office Version
- 2019
- Platform
- Windows
Good Morning from California,
I am trying to turn a subroutine that I have borrowed from @hiker95 into a function but I cannot get the output the dictionary to the activecell. I have tried a number of ways, but I just can't figure it out. I have verified that all of the values are being stored in the dictionary, but can't seem to output them to the activecell. Thank you in advance, here is the code:
I am trying to turn a subroutine that I have borrowed from @hiker95 into a function but I cannot get the output the dictionary to the activecell. I have tried a number of ways, but I just can't figure it out. I have verified that all of the values are being stored in the dictionary, but can't seem to output them to the activecell. Thank you in advance, here is the code:
VBA Code:
Function Unique(Duplicated As Range)
Dim d As Object, c As Variant, dup As Long, output As Range
Set output = ActiveCell
Set d = CreateObject("Scripting.Dictionary")
c = Duplicated
For dup = 1 To UBound(c, 1)
d(c(dup, 1)) = 1
Next dup
'Dim key As Variant
' For Each key In d.keys
' Debug.Print key, d(key)
'Next key
Range(output).Resize(d.Count) = Application.Transpose(d.keys)
End Function