Monday, February 17, 2014

Combo box on a user form:using unique range

Use this code in userform with initialize event
Private Sub UserForm_Initialize()
Dim a  As Integer
Dim vlu, ele
a = Application.CountA(Range("A:A"))
''''initializing1

Me.ComboBox1.Clear
        With Sheets("sheet1").Range("e2:e" & a)
            vlu = .Value
        End With
        With CreateObject("scripting.dictionary")
            .comparemode = 1
            For Each element In vlu
                If Not .exists(element) Then .Add element, Nothing
            Next
            If .Count Then Me.ComboBox1.List = Application.Transpose(.keys)
        End With
        Set element = Nothing

        Set vlu = Nothing

No comments:

Post a Comment