ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Milti Column Combobox (https://www.excelbanter.com/excel-programming/328016-milti-column-combobox.html)

Virginia

Milti Column Combobox
 
I have a form with a multicolumn combobox (CBNames). it gets its list from
columns a, B, and C of a worksheet. (Number, FirstName, LastName) i have the
column count set at 3, and the column widths set appropriately. when a user
clicks the arrow to "Drop Down" the combobox, and he/she selects an item from
the list, what is shown in the box is just the number, the first column. is
there a way to get it to display all 3 items for that row in the combobox
after it is selected? TIA

keepITcool

Milti Column Combobox
 

you can select 1 column to be displayed
when the combobox is not 'dropped'.

You do this by setting the TextColumn = 2
and it will show the second column.

To display the concatenated name you'd have to include
a fourth column with the data you want displayed.

If you dispense with the convenience of
using ListFillRange but populate the combo's list
yourself then you dont need need to change your actual data.

Sub Combofill()

Dim itm As Range

With Me.ComboBox1
'this ought to be set in designer
.ListFillRange = ""
.ColumnCount = 4
.ColumnWidths = "18pt;72pt;72pt;0"
.BoundColumn = 1
.TextColumn = 4

'this would normally run
.Clear
For Each itm In Range("a1:a40")
If itm(1, 1) < "" Then
.AddItem itm(1)
.List(.ListCount - 1, 1) = itm(1, 2)
.List(.ListCount - 1, 2) = itm(1, 3)
.List(.ListCount - 1, 3) = itm(1, 2) & ", " & itm(1, 3)
End If
Next
End With
End Sub






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Virginia wrote :

I have a form with a multicolumn combobox (CBNames). it gets its
list from columns a, B, and C of a worksheet. (Number, FirstName,
LastName) i have the column count set at 3, and the column widths set
appropriately. when a user clicks the arrow to "Drop Down" the
combobox, and he/she selects an item from the list, what is shown in
the box is just the number, the first column. is there a way to get
it to display all 3 items for that row in the combobox after it is
selected? TIA



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

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