Combobox - Problem on AddItem
Typo!!!!
Change this line:
..list(.listindex-1) = cells(i,"B")
to
..list(.listindex-1, 1) = cells(i,"B").Text
I missed the second dimension and I didn't qualify the range (.value or .text).
Dave Peterson wrote:
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
--
Dave Peterson
|