You need quotes around the "Scripting.Dictionary" in the
CreateObject function. E.g.,
Set Dic = CreateObject("Scripting.Dictionary")
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"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/