Selected Listbox Value to Textbox

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try like this

Code:
Private Sub CommandButton1_Click()
TextBox1.Value = ListBox1.Value
End Sub
 
Upvote 0
This could be one way:

<font face=Calibri><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> ListBox1_Exit(<SPAN style="color:#00007F">ByVal</SPAN> Cancel <SPAN style="color:#00007F">As</SPAN> MSForms.ReturnBoolean)<br>    Me.TextBox1.Value = Me.ListBox1.Value<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Although you didn't mention if your controls are on a worksheet or user form.

HTH,
 
Upvote 0
Also...

Private Sub CommandButton1_Click()
Me.TextBox1.Value = Me.ListBox1.List(Me.ListBox1.ListIndex)
End Sub
 
Upvote 0
Hi,
I have more 6 columns in my listbox. If i selected a row in the list box the first column should be displayed in textbox1 and second column in textbox2 and so on for all the 6 textboxes. How to do it. Please help me

Regards
 
Upvote 0
Hi,
I have more 6 columns in my listbox. If i selected a row in the list box the first column should be displayed in textbox1 and second column in textbox2 and so on for all the 6 textboxes. How to do it. Please help me
My controls are on a user form
Regards

This could be one way:

Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Me.ListBox1.Value
End Sub


Although you didn't mention if your controls are on a worksheet or user form.

HTH,
 
Upvote 0
Hi,
I have more 6 columns in my listbox. If i selected a row in the list box the first column should be displayed in textbox1 and second column in textbox2 and so on for all the 6 textboxes. How to do it. Please help me
My controls are on a user form
Regards


Also...

Private Sub CommandButton1_Click()
Me.TextBox1.Value = Me.ListBox1.List(Me.ListBox1.ListIndex)
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,485
Messages
6,113,931
Members
448,533
Latest member
thietbibeboiwasaco

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