PDA

View Full Version : Solved: .AddItme help



wolf.stalker
11-07-2009, 03:23 AM
Can someone give me an idea why this error's out?

For iLCV = 1 To 10

ActiveWorkbook.Worksheets("Form").cmbSite.AddItem = Range("B" & iLCV).Text

Next iLCV

I am getting runtime error 438 here.

On a worksheet named Form, i have a combo box named cmbSite. I am trying to loop through (in this case) 10 rows of data to populate that combo box.

the cell where the box is shows =EMBED("Forms.ComboBox.1","")

thanks for the help

p45cal
11-07-2009, 03:30 AM
remove the = sign?

You could do this with one line (I haven't qualified 'Range("B1:B10").Value' so this assumes you've made sure the active sheet is the right sheet - this is no different from your own code in this respect)
ActiveWorkbook.Worksheets("Form").cmbsite.List = Range("B1:B10").Value and if you wanted the combobox list to update itself automatically when the values in the range change use:
ActiveWorkbook.Worksheets("Form").cmbsite.ListFillRange = "B1:B10" (this last assumes that the range B1:B10 is on the Forms sheet)

mdmackillop
11-07-2009, 03:36 AM
Remove "="

wolf.stalker
11-07-2009, 06:02 AM
Remove "="

yup yup, figured that out shortly after i posted. came back here three times to remove / delete post but site was down?

anyway, thanks for the help!

mdmackillop
11-07-2009, 06:38 AM
You could also consider a Dynamic Range Name and the ListFillRange property to fiil the combo.