View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chris A[_3_] Chris A[_3_] is offline
external usenet poster
 
Posts: 11
Default Range to combobox- forget the blanks?

I saw a post not long ago showing how to populate a combobox from vba, using
a range of cells but ignoring the blanks. Excellent just what i needed,
However, i can't get mine working right, I get permission denied on my other
userform which i use to call the next, using the userform.show at the end of
my sub. This only happens when I add a loop on the other form

Here's what I saw.. I wonder if somebody could explain the for each line. Or
post another solution that may help me solve my problem TIA
Chris

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