Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Multicolumn combobox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gromit - 23 Jan 2006 07:04 GMT
In his blog, Dick Kusleika gives this code for populating a listbox. It
assumes the listbox has been set to to have a column count of 3, and
that there is data in columns A, B and C of Sheet 1. I've checked the
code and it works fine. However, I've tried using the same code to
populate a combobox, but it doesn't seem to work. Anyone any idea why?

Thanks, G

Private Sub UserForm_Initialize()
Dim cell As Range
Dim Rng As Range

With ThisWorkbook.Sheets(”Sheet1″)
Set Rng = .Range(”A2″, .Range(”A2″).End(xlDown))
End With

For Each cell In Rng.Cells
With Me.ListBox1
.AddItem cell.Value
.List(.ListCount - 1, 1) = cell.Offset(0, 1).Value
.List(.ListCount - 1, 2) = cell.Offset(0, 2).Value
End With
Next cell

End Sub

Signature

Gromit

Patrick Molloy - 23 Jan 2006 07:36 GMT
Option Explicit
Private Sub UserForm_Initialize()
 Dim cell As Range

 With ComboBox1

     For Each cell In Range("MyData").Columns(1).Cells
         .AddItem cell.Value
         .List(.ListCount - 1, 1) = cell.Offset(0, 1).Value
         .List(.ListCount - 1, 2) = cell.Offset(0, 2).Value
     Next cell
   
 End With

End Sub

> In his blog, Dick Kusleika gives this code for populating a listbox. It
> assumes the listbox has been set to to have a column count of 3, and
[quoted text clipped - 21 lines]
>
> End Sub
Gromit - 23 Jan 2006 16:14 GMT
Thanks Patrick,

This works fine, thanks. I tried Dick's again for the 5th time, and
this time it works also. I must have been doing something stupid.

Thanks again,

Graham

Signature

Gromit

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.