Hi.. i have this this code and this is working perfect.. but instead of "ComboBox2" i want to use "TextBox1"... please help me revised the code.. thanks..
Private Sub userform_initialize()
Dim x
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("CustAdd")
For Each r In .Range("A1", .Range("A65536").End(xlUp))
If Not IsEmpty(r) And Not dic.exists(r.Value) Then
dic.Add r.Value, Nothing
End If
Next
End With
x = dic.keys
Me.ComboBox1.List = x
End Sub
Private Sub ComboBox1_Change()
Me.ComboBox2.Clear: Me.ComboBox2.Clear
Set dic = CreateObject("Scripting.dictionary")
With Sheets("CustAdd")
For Each r In .Range("A1", .Range("A65536").End(xlUp))
If r = Me.ComboBox1.Value Then
If Not dic.exists(r.Offset(, 1).Value) Then
Me.ComboBox2.AddItem r.Offset(, 1)
dic.Add r.Offset(, 1).Value, Nothing
End If
End If
Next
End With
With Me.ComboBox2
If .ListCount = 1 Then .ListIndex = 0
End With
End Sub
Private Sub userform_initialize()
Dim x
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("CustAdd")
For Each r In .Range("A1", .Range("A65536").End(xlUp))
If Not IsEmpty(r) And Not dic.exists(r.Value) Then
dic.Add r.Value, Nothing
End If
Next
End With
x = dic.keys
Me.ComboBox1.List = x
End Sub
Private Sub ComboBox1_Change()
Me.ComboBox2.Clear: Me.ComboBox2.Clear
Set dic = CreateObject("Scripting.dictionary")
With Sheets("CustAdd")
For Each r In .Range("A1", .Range("A65536").End(xlUp))
If r = Me.ComboBox1.Value Then
If Not dic.exists(r.Offset(, 1).Value) Then
Me.ComboBox2.AddItem r.Offset(, 1)
dic.Add r.Offset(, 1).Value, Nothing
End If
End If
Next
End With
With Me.ComboBox2
If .ListCount = 1 Then .ListIndex = 0
End With
End Sub