Inserting Data into Textbox from Rowsource

nimesh29

New Member
Joined
Mar 20, 2013
Messages
26
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.

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
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top