Populating userform combo boxes

MattMurdock

New member
Joined
Jul 18, 2012
Messages
8
Reaction score
0
Points
0
Hi I'm having trouble populating a UserForm combo box

Here's my code, any help would be great-

Code:
Private Sub ArchiveForm_Initialize()
Dim cPart As Range
Dim cLoc As Range
Dim ws As Worksheet
Set ws = Worksheets("Calibration Data")
For Each cPart In ws.Range("Archives")
  With Me.ComboBox2
    .AddItem cPart.Value
    .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
  End With
Next cPart
For Each cLoc In ws.Range("Years")
  With Me.ComboBox1
    .AddItem cLoc.Value
    .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
  End With
Next cLoc
End Sub
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,521
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
Try this:


Code:
Private Sub UserForm_Initialize()Dim cPart As Range
Dim cLoc As Range
Dim ws As Worksheet
Set ws = Worksheets("Calibration Data")
For Each cPart In ws.Range("Archives")
  With Me.ComboBox2
    .AddItem cPart.Value
    .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
  End With
Next cPart
For Each cLoc In ws.Range("Years")
  With Me.ComboBox1
    .AddItem cLoc.Value
    .List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
  End With
Next cLoc
End Sub
 
Top