Selected Listbox Value to Textbox

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try like this

Code:
Private Sub CommandButton1_Click()
TextBox1.Value = ListBox1.Value
End Sub
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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,
 

tlowry

Well-known Member
Joined
Nov 3, 2011
Messages
1,367
Also...

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

klnp_mysore

Board Regular
Joined
Mar 2, 2011
Messages
62

ADVERTISEMENT

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
 

klnp_mysore

Board Regular
Joined
Mar 2, 2011
Messages
62
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,
 

klnp_mysore

Board Regular
Joined
Mar 2, 2011
Messages
62
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,914
Messages
5,598,840
Members
414,261
Latest member
KatieBsc

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
Top