Solved: array function help
hi,
I have a user form with many combo boxes.
All my combo box list items are extracted from another workbooks.
Eg. for combo box 1:
Code:
Workbooks.Open (.....)
Set DB = ActiveWorkbook
RowCount = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
DB_RANGE = "A2:A" & RowCount
With Me.ComboBox1
For Each listMaterialType In Worksheets("Sheet1").Range(DB_RANGE)
.AddItem listMaterialType.Value
.List(.ListCount - 1, 1) = listMaterialType.Offset(0, 1).Value
Next listMaterialType
End With
DB.Close False
This work fine. But when i want to do it for many combo boxes, I find that there are many repeat codes. Can someone show me how to make this code into a function to return array and use it in combo box 1, combo box2 ...etc? Many thanks.