Scripting.Dictionary question
Jennifer,
You need to add a reference (ToolsReferences) to "Microsoft Scripting
Runtime".
Depending what you are doing, you may not need this at all, as VBA has a
Collection object which behaves similar to the Dictionary object.
NickHK
P.S. You should aware that using "New" this way:
Dim mares As New Scripting.Dictionary
will mean that
If mares Is Nothing Then
will never evaluate to True. This is because an instance of the class will
be created everytime the variable "mares" is referred to, if it does not
currently refer to an instance.
Using the 2 part:
Dim mares As Scripting.Dictionary
Set mares = New Scripting.Dictionary
avoids this.
"Jennifer" wrote in message
...
With the following code i keep getting this error. Can you help?
***Compile Error
***User_defined not type defined
Private Sub LoadMares()
Dim mares As New Scripting.Dictionary (THIS IS WHAT IS HIGHLIGHTED)
Dim index As Long
Dim Mare As String
For index = 2 To Source.Rows.Count
Mare = Source.Cells(index, 1)
If Not mares.Exists(Mare) Then
mares.Add Mare, Mare
cmbMare.AddItem Mare
End If
Next
End Sub
--
Though daily learning, I LOVE EXCEL!
Jennifer
|