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
Ken Puls, FCPA, FCMA, MS MVP
Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!
Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter
If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.
Bookmarks