ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Linking List Boxes and Textboxes (https://www.excelbanter.com/excel-programming/332418-linking-list-boxes-textboxes.html)

peter_rivera

Linking List Boxes and Textboxes
 

Good morning all,

On a userform, I want to link a listbox to several other textboxes on
the form so that when the listbox changes all of the other values in
the textboxes will change.

Listbox - Name - Textboxes = address, phone, etc...

How can I do this in Excel? Thanks!


--
peter_rivera
------------------------------------------------------------------------
peter_rivera's Profile: http://www.excelforum.com/member.php...o&userid=24495
View this thread: http://www.excelforum.com/showthread...hreadid=380885


Tom Ogilvy

Linking List Boxes and Textboxes
 
Private Sub Listbox1_Click()
textbox1.Text = Listbox1.List(Listbox1.ListIndex,0)
textbox2.Text = Listbox1.List(Listbox1.ListIndex,1)
' etc

End Sub

--
Regards,
Tom Ogilvy


"peter_rivera"
wrote in message
news:peter_rivera.1qzhqq_1119369976.8997@excelforu m-nospam.com...

Good morning all,

On a userform, I want to link a listbox to several other textboxes on
the form so that when the listbox changes all of the other values in
the textboxes will change.

Listbox - Name - Textboxes = address, phone, etc...

How can I do this in Excel? Thanks!


--
peter_rivera
------------------------------------------------------------------------
peter_rivera's Profile:

http://www.excelforum.com/member.php...o&userid=24495
View this thread: http://www.excelforum.com/showthread...hreadid=380885




peter_rivera[_2_]

Linking List Boxes and Textboxes
 

Thanks, the code works to a degree...
Instead of getting information (phones numbers, addresses) from the
linked worksheet, the textboxes merely copy what is in the listbox.

How do I correct this? Thanks!


--
peter_rivera
------------------------------------------------------------------------
peter_rivera's Profile: http://www.excelforum.com/member.php...o&userid=24495
View this thread: http://www.excelforum.com/showthread...hreadid=380885


Tom Ogilvy

Linking List Boxes and Textboxes
 
Private Sub Listbox1_Click()
Dim rng as Range
set rng = Range(Listbox1.RowSource).Columns(1).Cells
set rng = rng(Listbox1.ListIndex + 1)
textbox1.Text = rng.Text
textbox2.Text = rng.offset(0,1).Text
textbox3.Text = rng.offset(0,2).Text
' etc

End Sub

--
Regards,
Tom Ogilvy


"peter_rivera"
wrote in message
...

Thanks, the code works to a degree...
Instead of getting information (phones numbers, addresses) from the
linked worksheet, the textboxes merely copy what is in the listbox.

How do I correct this? Thanks!


--
peter_rivera
------------------------------------------------------------------------
peter_rivera's Profile:

http://www.excelforum.com/member.php...o&userid=24495
View this thread: http://www.excelforum.com/showthread...hreadid=380885




peter_rivera[_3_]

Linking List Boxes and Textboxes
 

Thanks Tom! It works now

--
peter_river
-----------------------------------------------------------------------
peter_rivera's Profile: http://www.excelforum.com/member.php...fo&userid=2449
View this thread: http://www.excelforum.com/showthread.php?threadid=38088



All times are GMT +1. The time now is 05:34 AM.

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