ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   List box to Text Box (https://www.excelbanter.com/excel-discussion-misc-queries/39115-list-box-text-box.html)

mully

List box to Text Box
 
Hi

On a userform I have a list box that consists of 4 columns e.g.

121 - Joe Bloggs - 493 -1647

I would like to do the following on the same userform after highligting the
line
121 - Joe Bloggs - 493 - 1647 - in the list box.

TextBox1 = 121
TextBox2 = Joe Bloggs
TextBox3 = 493
TextBox4 =1647

all I end up with when trying to do it is that all the TextBoxes have 121
in them

Any help to solve this problem is much appreciated

Mully



dominicb


Good morning Mully

This piece of code should help, in your Userorm_Initialize:

Private Sub UserForm_Initialize()
TextBox1 = ActiveCell.Value
TextBox2 = ActiveCell.Offset(, 1).Value
TextBox3 = ActiveCell.Offset(, 2).Value
TextBox4 = ActiveCell.Offset(, 3).Value
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=393594


mully


Good Morning Dominic

Thanks for the help installed the code as you recommended and on opening
the UserForm showed all the details from the Row on the Active Sheet and on
clicking the command button "Add Info" it put the row details on another
sheet correctly.
However on highlighting a row in the List Box no details showed in the text
boxes I had to go back to the sheet select a row and the new details showed.
What I wanted to do was get the details from the List Box on the UserForm and
just click "Add Info" Is this possible ????

Thanks Mully

"dominicb" wrote:


Good morning Mully

This piece of code should help, in your Userorm_Initialize:

Private Sub UserForm_Initialize()
TextBox1 = ActiveCell.Value
TextBox2 = ActiveCell.Offset(, 1).Value
TextBox3 = ActiveCell.Offset(, 2).Value
TextBox4 = ActiveCell.Offset(, 3).Value
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=393594



dominicb


Hi Mully

Apologies for the delay in my reply.

It depends on exactly how you've set up your list box, but I've just
tested this piece of code and it seemed to be working OK - is this what
you wanted?

Private Sub ListBox1_Click()
TextBox1.Value = ListBox1.List(, 0)
TextBox2.Value = ListBox1.List(, 1)
TextBox3.Value = ListBox1.List(, 2)
TextBox4.Value = ListBox1.List(, 3)
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=393594


mully

Hi Dominic
Been busy myself -- out all morning.

Just the job and spot on -- thanks for all your help

much appreciated

Mully

"dominicb" wrote:


Hi Mully

Apologies for the delay in my reply.

It depends on exactly how you've set up your list box, but I've just
tested this piece of code and it seemed to be working OK - is this what
you wanted?

Private Sub ListBox1_Click()
TextBox1.Value = ListBox1.List(, 0)
TextBox2.Value = ListBox1.List(, 1)
TextBox3.Value = ListBox1.List(, 2)
TextBox4.Value = ListBox1.List(, 3)
End Sub

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=393594




All times are GMT +1. The time now is 10:30 AM.

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