Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Combobox to Show 2 values in same row

I can get 2 columns to display in a Combobox,
but i am unable to work out how to populate the other value from code.

Currently i use this:

Private Sub ComboBox2_DropButtonClick()
Application.ScreenUpdating = False
If ComboBox2.ListCount 0 Then Exit Sub
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("to be Done").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("to be Done")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" Then
ComboBox2.AddItem Cells(myrow, 3)
End If
Next
End With
Application.ScreenUpdating = True
End Sub

But i want to add to the Combobox a Column to display the value in Column A as well as Column C in it.

How do i do this the above ?

Corey....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Combobox to Show 2 values in same row

Corey, you will need to change your method of adding items from a loop to a ListFillRange if you want more than 1 column. The secret here is to set a 3-column combobox, but hide the 2nd column.

Private Sub ComboBox2_DropButtonClick()
Application.ScreenUpdating = False
'If ComboBox2.ListCount 0 Then Exit Sub
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("to be Done").Cells(Rows.Count, "C").End(xlUp).Row
With Me.ComboBox2
.ListFillRange = "A1:C" & LastCell
.ColumnCount = 3
.ColumnWidths = "90;0;90" 'hide col 2
.BoundColumn = 3 'sets .Value
.TextColumn = 3 'sets .Text
End With
Application.ScreenUpdating = True
End Sub

Mike F
"Corey" wrote in message ...
I can get 2 columns to display in a Combobox,
but i am unable to work out how to populate the other value from code.

Currently i use this:

Private Sub ComboBox2_DropButtonClick()
Application.ScreenUpdating = False
If ComboBox2.ListCount 0 Then Exit Sub
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("to be Done").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("to be Done")
.Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) < "" Then
ComboBox2.AddItem Cells(myrow, 3)
End If
Next
End With
Application.ScreenUpdating = True
End Sub

But i want to add to the Combobox a Column to display the value in Column A as well as Column C in it.

How do i do this the above ?

Corey....
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Combobox to Show 2 values in same row

After: ComboBox2.AddItem Cells(myrow, 3)
Insert: ComboBox2.Column(1, myrow - 1) = Cells(myrow, 1)
'Column is a 0 base array

Hth,
Merjet


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Combobox to Show 2 values in same row

perfect thanks
"merjet" wrote in message
oups.com...
After: ComboBox2.AddItem Cells(myrow, 3)
Insert: ComboBox2.Column(1, myrow - 1) = Cells(myrow, 1)
'Column is a 0 base array

Hth,
Merjet



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
one column of cells show ####. Values show when I open it. Help grantljg Excel Discussion (Misc queries) 3 September 18th 07 09:19 PM
How does one show an intital value in the combobox susan Excel Programming 2 September 6th 06 09:48 PM
ComboBox to show a range TimT Excel Programming 2 August 8th 05 07:58 PM
Show Filename Only in ComboBox Pulldown D.Parker Excel Discussion (Misc queries) 16 June 29th 05 02:46 PM
Fill values into a listbox matching selected values from a combobox Jon[_19_] Excel Programming 4 January 25th 05 04:25 PM


All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"