View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Add Dynamic Array to List Box

Why not skip the array and load the listbox directly. Assuming your data
is in Columns A and B (Sheet1) with headers in row 1 then try:

Private Sub UserForm_Initialize()
Dim eRow As Long
Dim i As Long
With Sheets("Sheet1")
eRow = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To eRow
If .Cells(i, 1).Value < .Cells(i, 2).Value Then
Me.ListBox1.AddItem .Cells(i, 1).Value
End If
Next i
End With
End Sub

Hope this helps
Rowan

JG Scott wrote:
I would like to loop through a range and, for each cell whose value
does not equal the value of the cell offset(0,1), add the cell's value
to an array. Then, after completing the loop, I would like to show a
form with a list box containing the array just created.

Thank you.