ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   TextBox linked to a ComboBox? (https://www.excelbanter.com/excel-discussion-misc-queries/176551-textbox-linked-combobox.html)

capt

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

Dave Peterson

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

capt

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


Chris Lavender

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





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

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