View Single Post
 
Old 01-20-2015, 08:50 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you are creating the combobox, then Greg's approach works well, but seeing that he has improved on my suggestion, I'll return the favour.

I would set the combobox to display only the first column, by setting the column count (here 2, but you can have more colums as required) and making all but the first column have a width of zero. As it is a combobox and not a list box, I would also add a prompt at the top of the list and set the listindex to that prompt i.e. 0
Code:
Private Sub UserForm_Initialize()
    With Me.ComboBox1
        .ColumnCount = 2
        .ColumnWidths = .Width & ",0"
        .AddItem
        .list(.ListCount - 1, 0) = "[Select City]"
        .list(.ListCount - 1, 1) = "" 
        .AddItem
        .list(.ListCount - 1, 0) = "Cleveland"
        .list(.ListCount - 1, 1) = "A city in northwestern Ohio, USA"
        .AddItem
        .list(.ListCount - 1, 0) = "Cincinnati"
        .list(.ListCount - 1, 1) = "A city in southwestern Ohio, USA"
        .ListIndex = 0
    End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote