Question : Combo  Box Fill from another Worksheet

I have a form frmCriteria (using Excel 2007) where I have two combo boxes.

I need  a way to fill the combo boxes from a worksheet called "List"

cboGroup would be filled using column A from the List sheet
cboUnit would be filled using column B from the List sheet

Thank you in advance.

Answer : Combo  Box Fill from another Worksheet

Have you tried setting the RowSource property of the combo boxes?

Prior to doing

frmCriteria.Show

you should run some code to set the RowSource properties.  The best way is to use the Load command and the Initialize event

So something like

frmCriteria.Load
frmCriteria.Show

--------

Private Sub frmCriteria_Initialize()
  frmCriteria.cboGroup.RowSource = "List!" & Worksheets("List").Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Address
  frmCriteria.cboUnit.RowSource = "List!" & Worksheets("List").Range("B1:B" & Range("B" & Rows.Count).End(xlUp).Row).Address
End Sub

----------
Basically, you need to make sure you Load the data before you Show the form.  If you hide the form instead of Unloading it, then the data would not automatically update just by re-showing the form.  You would need to reload.  Using Unload instead of Hide would take care of this, but always Loading before Showing is a good way to avoid any issues.

You may need to adjust the ranges I used.  I was assuming the data you wanted to populate with started on Row 1, and that you wanted everything from those columns.

Let me know if you have any questions, or if it doesn't work properly.

Cheers,
WC
Random Solutions  
 
programming4us programming4us