View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Combobox - Problem on AddItem

Private Sub UserForm_Initialize()

Dim i As Long
Dim ComboRange As Range

With me.ComboBox1
'just do this stuff once--not in a loop
.columncount = 2
.ColumnWidths = "50;80"

i = 5
While (ActiveSheet.Cells(1 + i, 11).value < 0)
i = i + 1
If ucase(Cells(1 + i, 11).Text) < "OK" _
And Cells(1 + i, 11).Text < "" Then
.additem cells(i,"A").value
.list(.listindex-1) = cells(i,"B")
End If
Wend
end with

End Sub

(Untested, uncompiled. Watch for typos.)

Eddie_SP wrote:

I tried this:

Private Sub UserForm_Initialize()

Dim i As Integer
Dim ComboRange As Range

i = 5
While (ActiveSheet.Cells(1 + i, 11) < 0)
i = i + 1
If Cells(1 + i, 11).Text < "OK" And Cells(1 + i, 11).Text < "" Then
ComboRange = Range("A" & i & ":B" & i)
With ComboBox1
.ColumnWidths = "50;80"
.AddItem ComboRange
End With
End If
Wend

End Sub

But it doesn't work...

=(


--

Dave Peterson