Hello 
this code will transfer the data from a list box to another userform by double clicking on it.
now instead of double clicking the row, I want to put a button, so that the user selects the row by clicking on it and then clicks on the button, which will transfer the data to the userform1.
Can someone help me to change the code for the button?
What should I add so that vba knows which row is selected?
This is the code I'm using:
Private Sub DataListBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'dim the variables
Dim i As Integer
On Error Resume Next
'find the selected list item
i = Me.DataListBox.ListIndex
'add the values to the text boxes
userform1.txtFrage.Value = Me.DataListBox.Column(2, i)
userform1.txtAntwort.Value = Me.DataListBox.Column(3, i)
userform1.txtID.Value = Me.DataListBox.Column(0, i)
On Error GoTo 0
End Sub
Bookmarks