comboBox vs Listbox

S

Steve

I'm stumped!!

I am trying to populate a Combobox from a range of data. Using the code
below, I can fill a listbox. However, If I add ComboBox1 to the form and
change the code below from "Me.ListBox1.AddItem cell.Value" to
"Me.ComboBox1.AddItem cell.Value", I get an error: Runtime error 70
Permission denied. Can someone help?

Private Sub UserForm_Initialize()
Dim cell As Range
Dim rng As Range

With ThisWorkbook.Sheets("shOrder")
Set rng = .Range("a4", .Range("a4").End(xlDown))
End With

For Each cell In rng.Cells
Me.ListBox1.AddItem cell.Value
Next cell
End sub
 
B

Bob Phillips

That sounds as though you have set the RowSource property in the Combobox,
which means you cannoty add to the combo.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 
S

Steve

Bob

That sounds right and is right!

Should have spotted that myself. Didn't even look at properties. Just swore
a lot. Strange that the latter didn't fix it <bg>.

--
Steve


Bob Phillips said:
That sounds as though you have set the RowSource property in the Combobox,
which means you cannoty add to the combo.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top