Displaying combobox value in textbox when combobox list is array

Prevost

Board Regular
Joined
Jan 23, 2014
Messages
198
Hi There. I have a combobox which I populated with a two dimensional array.

Code:
Sub Test()
    With ComboBox1
        .List = DisplayArray
    End With
    Textbox1 = ComboBox1.Value
End Sub

The textbox value now just contains the value in the first column of the array (the array only has 2 columns). Am I able to have the textbox display both values as displayed in the combobox?

Thanks!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi,
try using the Column Property:

Code:
Private Sub ComboBox1_Change()
    With Me.ComboBox1
        Me.TextBox1 = .Column(0) & " " & .Column(1)
    End With
End Sub

Column is a zero-based property, the first column is 0, the second 1 and so on.


Dave
 
Upvote 0
Thank you! That is what I needed. Is the same methodology used to display both array values in the combobox as well? Because right now only the first array value displays in the combobox once a value is selected.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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
Back
Top