Hello:
I am trying to insert selected Data from RowSource list into Textbox2 in Userform1. My Rowsource list has two columns and i like to have information from both columns be inserted into the Textbox2 with possible dash between them [12 12345 - Test Text]. However, i am only able to get column 'A' to show up in textbox2.
I tried several different codes but, couldn't get it to show up!!!
Thanks in advance for your help.
I am trying to insert selected Data from RowSource list into Textbox2 in Userform1. My Rowsource list has two columns and i like to have information from both columns be inserted into the Textbox2 with possible dash between them [12 12345 - Test Text]. However, i am only able to get column 'A' to show up in textbox2.
I tried several different codes but, couldn't get it to show up!!!
Thanks in advance for your help.
Code:
Private Sub CSIList_Click()
End Sub
Private Sub UserForm_Initialize()
'<--This will recall source of the List-->
Me.CSIList.RowSource = "CSI"
End Sub
Private Sub CSISearch_Change()
Dim WS As Worksheet
Dim LastRow As Long
Dim A As Long
Dim c As Range, Firstaddress As String
If Len(Me.CSISearch) = 0 Then
Me.CSIList.RowSource = "CSI"
Else
Me.CSIList.RowSource = ""
Set WS = Worksheets("CSI List")
With WS
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("a1:B" & LastRow)
Set c = .Find(Me.CSISearch, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
Firstaddress = c.Address
Do
Me.CSIList.AddItem WS.Range("A" & c.Row)
Me.CSIList.Column(1, Me.CSIList.ListCount - 1) = WS.Range("B" & c.Row)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> Firstaddress
End If
End With
End With
End If
End Sub
Private Sub CSIButton_Click()
'<--Below code is used to insert selection into userform
UserForm1.TextBox2.Value = CSIList.Value
Unload Me
End Sub
Private Sub CSICancel_Click()
Unload Me
End Sub