I am trying to make use of a scripting dictionary to create an array of unique values in an existing array. When I run the following code, I get a "Argument not Optional" error with the line d2.Add (DateReport(14, i)). This project has nearly identical code to create another scripting dictionary name d1 in a separate module and it works just fine. The DateReport array is a dynamic array which contains 23 "rows" and a dynamic number of "columns". It is my intent to search all of the records in row 14 and determine the unique values to report to UserForm2.ListBox1. I have confirmed the contents of the DateReport array by adding the output of the array to a separate worksheet. Also, note that "DateReport" is declared "Public" in a separate module where I declare my non-private variables.
Any assistance with this problem would be greatly appreciated!
[code]Sub DepthSelect()
Dim d2 As Scripting.Dictionary
Dim d2Array() As Variant
Set d2 = CreateObject("Scripting.Dictionary")
For i = LBound(DateReport, 1) To UBound(DateReport, 1)
If d2.Exists(DateReport(14, i)) = False Then
d2.Add DateReport(14, i)
End If
Next i
d2Array = d2.Keys
UserForm2.ListBox1.List = d2Array
UserForm2.Show
End Sub[code]
Thanks again,
SoilTech
Re: Scripting.Dictionary error "Argument not Optional"
You are missing, "Item" property.