![]() |
Add Dynamic Array to List Box
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. |
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. |
All times are GMT +1. The time now is 05:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com