Combo Box addItem question

S

strataguru

Hi,

I am looking to populate a combox with values from a column in a
worksheet..... but not every row is populated. How do I filter out the
rows that have no values from being populated in the combo box?

Also - after my macro loads the userform - in the userform initialize
function I'd like to query a specific worksheet to pull in the values
explained above - but I'm getting an error that the object isn't
valid.

Any ideas?
Thanks!
 
T

Tom Ogilvy

Private Sub Userform_Initialize()
Dim sh as Worksheet
Dim cell as Range
set sh = Worksheet("sheet1")

for each cell in sh.range(sh.cells(2,5),sh.cells(rows.count,5).End(xlup))
if not isempty(cell) then
combobox1.AddItem cell
end if
Next

End sub
 

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

Top