Can I pass parameters to a sub to populate a combo box?

trailbarge

New Member
Joined
Sep 24, 2008
Messages
4
I have a list of frames with engineering data on a worksheet. I am populating a combo box with the frame names (I'll be using the index from this combo box for other data lookup once I get this ironed out). The commented out stuff in the initialize code you see below works.

As I will be populating several combo boxes from several lists, I'd like to have one subroutine for the looping and pass to it the form and combo box to be populated and also the worksheet from which to grab the data.

Something like:
GetFrameList(cboFramelist, FRAMEDATA)

and the sub to look like
cboFramelist.additem Worksheets(FRAMEDATA).Cells... blahblahblah

Is there any hope or will I be typing do loops until the cows come home?

Thanks, all
Paul
====================================================
Sub UserForm_Initialize()
'Dim i As Integer
'i = 4
'Do While Worksheets("FRAMEDATA").Cells(i, 1) <> ""
' UserForm1.CboFramelist.AddItem Worksheets("FRAMEDATA").Cells(i, 1)
' i = i + 1
'Loop
GetFrameList ()
End Sub

Sub GetFrameList()
Dim i As Integer
i = 4
Do While Worksheets("FRAMEDATA").Cells(i, 1) <> ""
UserForm1.CboFramelist.AddItem Worksheets("FRAMEDATA").Cells(i, 1)
i = i + 1
Loop
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,942
Messages
6,127,807
Members
449,408
Latest member
Bharathi V

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top