ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vlookup (https://www.excelbanter.com/excel-programming/328070-vlookup.html)

Patrick Simonds

vlookup
 
Would it be possible to use a variable returned by a ListBox, on a UserForm,
to place a value in a TextBox on the same UserForm? Maybe on a ListBoxClick
routine.



William[_2_]

vlookup
 
Hi Patrick

If I have understood you correctly, try....

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1 = ""
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
TextBox1 = ListBox1.List(i)
Exit Sub
End If
Next i
End Sub


--

XL2003
Regards

William



"Patrick Simonds" wrote in message
...
Would it be possible to use a variable returned by a ListBox, on a
UserForm, to place a value in a TextBox on the same UserForm? Maybe on a
ListBoxClick routine.




Bob Phillips[_6_]

vlookup
 
Simpler

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1.Text = ListBox1.Value
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"William" wrote in message
...
Hi Patrick

If I have understood you correctly, try....

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1 = ""
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
TextBox1 = ListBox1.List(i)
Exit Sub
End If
Next i
End Sub


--

XL2003
Regards

William



"Patrick Simonds" wrote in message
...
Would it be possible to use a variable returned by a ListBox, on a
UserForm, to place a value in a TextBox on the same UserForm? Maybe on a
ListBoxClick routine.






Patrick Molloy

vlookup
 
Private Sub ListBox1_Click()
TextBox1.Text = ListBox1.Value
End Sub


;)

"Bob Phillips" wrote in message
...
Simpler

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1.Text = ListBox1.Value
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"William" wrote in message
...
Hi Patrick

If I have understood you correctly, try....

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1 = ""
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
TextBox1 = ListBox1.List(i)
Exit Sub
End If
Next i
End Sub


--

XL2003
Regards

William



"Patrick Simonds" wrote in message
...
Would it be possible to use a variable returned by a ListBox, on a
UserForm, to place a value in a TextBox on the same UserForm? Maybe on
a
ListBoxClick routine.








Bob Phillips[_6_]

vlookup
 
Patrick,

You can never have too many superfluous variables :-)

Bob


"Patrick Molloy" wrote in message
...
Private Sub ListBox1_Click()
TextBox1.Text = ListBox1.Value
End Sub


;)

"Bob Phillips" wrote in message
...
Simpler

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1.Text = ListBox1.Value
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"William" wrote in message
...
Hi Patrick

If I have understood you correctly, try....

Private Sub ListBox1_Click()
Dim i As Integer
TextBox1 = ""
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
TextBox1 = ListBox1.List(i)
Exit Sub
End If
Next i
End Sub


--

XL2003
Regards

William



"Patrick Simonds" wrote in message
...
Would it be possible to use a variable returned by a ListBox, on a
UserForm, to place a value in a TextBox on the same UserForm? Maybe

on
a
ListBoxClick routine.











All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com