Hi I need to populate TextBox1 from ComboBox2... I need to get the value of ComboBox2 to appear in TextBox1 whatever the value of ComboBox2 is.. irregardless if it is Blank, Number, Text.. my point is whatever the value in ComboBox should fill the TextBox..
I have this code that auto populate Combobox2 & Textbox1 but there are times that i need to change the value of ComboBox2 ... and it will give me empty results on my TextBox..please help..
here is my current code:
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
TextBox1.Text = ComboBox2.Column(1)
End Sub
I have this code that auto populate Combobox2 & Textbox1 but there are times that i need to change the value of ComboBox2 ... and it will give me empty results on my TextBox..please help..
here is my current code:
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
TextBox1.Text = ComboBox2.Column(1)
End Sub