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
 
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
 
Back
Top