Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default TextBox linked to a ComboBox?

Is there a way to link a textbox to a combobox list?
I have a combobox1 on my userform that I want to be able to select a item on
that list and which in turn puts an associated item in textbox1.
To give you an example:
My list in sheet3("list")

A B
k5400 Travel
K5000 Physio
K5601 Surg
and so on.....ComboBox1 is linked to column "A"

If I select "K5400" in the combobox1 then I want "Travel" to come up in
textbox1

any ideas?
--
capt
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default TextBox linked to a ComboBox?

How about something like:

Option Explicit
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
Me.TextBox1.Value = ""
Else
Me.TextBox1.Value = .List(.ListIndex, 1)
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.ComboBox1
.RowSource = Worksheets("Sheet1").Range("A1:B3").Address(extern al:=True)
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "22;0" 'hide the second column
End With
End Sub




capt wrote:

Is there a way to link a textbox to a combobox list?
I have a combobox1 on my userform that I want to be able to select a item on
that list and which in turn puts an associated item in textbox1.
To give you an example:
My list in sheet3("list")

A B
k5400 Travel
K5000 Physio
K5601 Surg
and so on.....ComboBox1 is linked to column "A"

If I select "K5400" in the combobox1 then I want "Travel" to come up in
textbox1

any ideas?
--
capt


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default TextBox linked to a ComboBox?

Thanks very much Dave,
It`s very complicated, but it works well.
--
capt


"Dave Peterson" wrote:

How about something like:

Option Explicit
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
Me.TextBox1.Value = ""
Else
Me.TextBox1.Value = .List(.ListIndex, 1)
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.ComboBox1
.RowSource = Worksheets("Sheet1").Range("A1:B3").Address(extern al:=True)
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "22;0" 'hide the second column
End With
End Sub




capt wrote:

Is there a way to link a textbox to a combobox list?
I have a combobox1 on my userform that I want to be able to select a item on
that list and which in turn puts an associated item in textbox1.
To give you an example:
My list in sheet3("list")

A B
k5400 Travel
K5000 Physio
K5601 Surg
and so on.....ComboBox1 is linked to column "A"

If I select "K5400" in the combobox1 then I want "Travel" to come up in
textbox1

any ideas?
--
capt


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default TextBox linked to a ComboBox?

Hi both
Wouldn't it be simpler just to set the LinkedCell property on both the
combobox and the textbox to the same cell; have the combobox ListFillRange
set to columns A and B; and have Column2 as the BoundColumn?

Best rgds
Chris Lav

"capt" wrote in message
...
Thanks very much Dave,
It`s very complicated, but it works well.
--
capt


"Dave Peterson" wrote:

How about something like:

Option Explicit
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex < 0 Then
Me.TextBox1.Value = ""
Else
Me.TextBox1.Value = .List(.ListIndex, 1)
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.ComboBox1
.RowSource =
Worksheets("Sheet1").Range("A1:B3").Address(extern al:=True)
.ColumnCount = 2
.BoundColumn = 1
.ColumnWidths = "22;0" 'hide the second column
End With
End Sub




capt wrote:

Is there a way to link a textbox to a combobox list?
I have a combobox1 on my userform that I want to be able to select a
item on
that list and which in turn puts an associated item in textbox1.
To give you an example:
My list in sheet3("list")

A B
k5400 Travel
K5000 Physio
K5601 Surg
and so on.....ComboBox1 is linked to column "A"

If I select "K5400" in the combobox1 then I want "Travel" to come up in
textbox1

any ideas?
--
capt


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Toolbox Textbox and Linked Cells Carol Sitea Excel Discussion (Misc queries) 2 March 14th 07 03:14 PM
VLOOKUP, linked cell &combobox Jaan Excel Worksheet Functions 0 December 11th 06 01:41 PM
select from combobox and show a price in textbox gem New Users to Excel 1 June 14th 06 11:37 AM
combobox /textbox value flow23 Excel Discussion (Misc queries) 0 April 19th 06 03:18 PM
UserForm TextBox/ComboBox question grasping@straws Excel Discussion (Misc queries) 1 February 2nd 05 11:14 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"