Hi everyone
I have a question about userform listbox?
I want to know about userform listbox can use key press (enter) for select data replace to click button(+)
VBA code below is code of button (+)
Private Sub CommandButton1_Click()
Dim lr As Long, i As Long
lr = Range("AE" & Rows.Count).End(3).Row + 1
If lr < 21 Then lr = 21
With ListBox1
For i = 0 To .ListCount - 1
If ListBox1.Selected(i) = True Then
Range("AE" & lr).Value = .List(i, 0)
Range("AG" & lr).Value = .List(i, 1)
Exit For
End If
Next
End With
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
TextBox1.SetFocus
End Sub
I have a question about userform listbox?
I want to know about userform listbox can use key press (enter) for select data replace to click button(+)
VBA code below is code of button (+)
Private Sub CommandButton1_Click()
Dim lr As Long, i As Long
lr = Range("AE" & Rows.Count).End(3).Row + 1
If lr < 21 Then lr = 21
With ListBox1
For i = 0 To .ListCount - 1
If ListBox1.Selected(i) = True Then
Range("AE" & lr).Value = .List(i, 0)
Range("AG" & lr).Value = .List(i, 1)
Exit For
End If
Next
End With
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
TextBox1.SetFocus
End Sub