#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 108
Default populate combo box

I need to populate a combo box on a userform. I need the combobox to have
two columns and for the columns to take their information from a worksheet.
The problem is that the two columns of information are not beside each other
so I cant get it to work. Can anyone hep?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default populate combo box

Maybe something like this will help:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
With Me.ComboBox1
If .ListIndex -1 Then
MsgBox .List(.ListIndex, 0) & vbLf & .List(.ListIndex, 1)
End If
End With
End Sub
Private Sub UserForm_Initialize()
Dim myRng As Range
Dim myCell As Range

With Worksheets("sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Me.ComboBox1
.ColumnCount = 2
For Each myCell In myRng.Cells
.AddItem myCell.Value
.List(.ListCount - 1, 1) = myCell.Offset(0, 2).Value
Next myCell
End With
End Sub




enyaw wrote:

I need to populate a combo box on a userform. I need the combobox to have
two columns and for the columns to take their information from a worksheet.
The problem is that the two columns of information are not beside each other
so I cant get it to work. Can anyone hep?


--

Dave Peterson
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
Populate a combo box damorrison Excel Discussion (Misc queries) 11 September 3rd 06 09:04 PM
Best way to populate worksheet from 2 combo boxes jswasson Excel Worksheet Functions 0 July 7th 06 01:21 PM
Populate a combo Box case54321 Excel Worksheet Functions 1 June 14th 05 02:53 PM
Populate embedded combo box Jahunga Excel Worksheet Functions 2 November 28th 04 11:26 PM
Populate embedded combo box Jahunga Excel Worksheet Functions 0 November 18th 04 10:17 AM


All times are GMT +1. The time now is 01:39 PM.

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"