I have a userform with multiple comboboxes (combobox1 -> combobox40)

I want to fill the combobox, preferably using .additem , so that the user
can't change it. Somehow, I can't set the cboBox variable.

This is what I've tried:

Sub FillAllComboBoxes()
dim cboBox as msforms.combobox
dim frmSettings as userform

frmSettings = SettingsForm ' the name of my userform

With frmSettings
.combobox1.additem = "FirstItem" 'works just fine
set cboBox = .combobox1 ' bugs out here
call FillcomboBox(cboBox)
End with
end sub


Sub FillcomboBox(cboBox as MsForms.combobox)

cboBox.additem = "value1"
cboBox.additem = "value2"

End sub

I can't get passed the
set cboBox = .combobox1
line without it bugging out.

Ideally, I'd like to cycle through the combobox using their numbers. I saw
this posting by Tom Ogilvy, but can't get it to work for a userform that is
not part of an active worksheet.

' this declaration is important
Dim cbx as MsForms.Combobox
.. . .
For i = 400 To myrow - 10 Step -1
With ActiveSheet.OLEObjects("ComboBox" & i)
.name = "ComboBox" & i + 1
set cbx = .Object
cbx.Name = "ComboBox" & i + 1
end with
Next i

--