View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default MultiColumn ComboBox Display

ColumnCount limits only the display and you still have access to the hidden
columns. You can see by selecting a value in the combo, then running:

MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 15)

which will display the 16th column of the selected row. Does not matter that
ColumnCount = 4.

I was wondering, if I made the 4th column as wide as the ComboBox
without limiting the number of columns, wouldn't that, in effect, give
me the appearance of only the 4th column appearing in the ComboBox?


I don't think so. To achieve that effect, you might need to resort to
something like:

Private Sub UserForm_Initialize()
Dim i As Integer, ColWidth As String
For i = 1 To Range(Me.ComboBox1.RowSource).Columns.Count
If i = 4 Then
ColWidth = ColWidth & Me.ComboBox1.Width & ";"
Else
ColWidth = ColWidth & 0 & ";"
End If
Next
ColWidth = Left(ColWidth, Len(ColWidth) - 1)
Me.ComboBox1.ColumnWidths = ColWidth
End Sub

IMO easier to do it the other way.

--
Tim Zych
www.higherdata.com
Compare data in workbooks and find differences with Workbook Compare
A free, powerful, flexible Excel utility

"Minitman" wrote in message
...
Hey Tim,

Thanks for the reply.

Question: By changing the column count, won't that be limiting the
number of columns in the row source?

I can see the column width should effectively hide the first three
columns, that is a real help!!!

I was wondering, if I made the 4th column as wide as the ComboBox
without limiting the number of columns, wouldn't that, in effect, give
me the appearance of only the 4th column appearing in the ComboBox?

Again, thanks for the pointer on the column widths.

-Minitman
On Fri, 30 May 2008 17:02:16 -0700, "Tim Zych"
<tzych@NOSp@mE@RTHLINKDOTNET wrote:

One way is to set the ColumnCount to 4 and the ColumnWidths to 0;0;0

--
Tim Zych
www.higherdata.com
Compare data in workbooks and find differences with Workbook Compare
A free, powerful, flexible Excel utility

"Minitman" wrote in message
. ..
Greetings,

I have a UserForm ComboBox with a RowSource of 27 rows and 20 columns.

How can I get only the values in the 4th column to be displayed in the
drop down window? Is this possible?

Anyone have any ideas, thoughts or links related to this question?

Any help will be appreciated.

-Minitman