You didn't follow my advice. My advice showed
Set Dic = CreateObject("Scripting.Dictionary")
You wrote
Set Dic = CreateObject(Scripting.Dictionary)
also
Dim Dic As New Scripting.Dictionary
shouldn't be used if you use late binding. You would use that for early
binding (creating a reference) and would not use the createobject line.
Dim dic as Object
for late binding
--
Regards,
Tom Ogilvy
"ajliaks " wrote in message
...
Hi,
Following your advice, I am trying this code, in order to show items
listed in combobox only once each item. (like autofilter), but it
doesn't work, (it gives mi error: Variable not defined and remarking
"Scripting")
Private Sub UserForm_Initialize()
'Set a reference to MS Scripting runtime
Set Dic = CreateObject(Scripting.Dictionary)
Dim Dic As New Scripting.Dictionary
Dim rSource As Range, cell As Range
Dim sVal As String
Dim MyList As String
'Point to specific column
MyList = "P3:P20"
Set rSource = Range("MyList")
With ChapExpCB
For Each cell In rSource.Cells
sVal = cell.Value
If Not Dic.Exists(sVal) Then
Dic.Add sVal, sVal
AddItem sVal
End If
Next
End With
Set Dic = Nothing
End Sub
Thanks in advance.
---
Message posted from http://www.ExcelForum.com/