Combobox add large range of cells

C

Corey

I have placed a Combobox(ActiveX) on a worksheet(Sheet2), but now i want to
populate it will all the values(that are not blank) in Sheet3 between
range("A2:A25000").

How do i do this without manually do this:

Combobox1.Additem Sheet3.Range("A2").value
Combobox1.Additem Sheet3.Range("A3").value
.....
.....
and so on?

Corey....
 
D

Dave Peterson

Dim myRng as range
dim myCell as range

set myrng = sheet3.range("a2:a25000")

'or if you potentially have lots of empty cells at the bottom
with sheet3
set myrng = .range("A2", .cells(.rows.count,"A").end(xlup))
end with

for each mycell in myrng.cells
if isempty(mycell.value) then
'skip it
else
combobox1.additem mycell.value
end if
next mycell
 

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