User List Box - List from Hidden range - VBA worng
Hi All
not my code, but I would love to fix it. The rows.value(i+1,1) --
statements are wrong.
How is it fixed please.
'fills in list box. stops at first empty row in project list
Private Sub UserForm_Initialize()
Dim orange As Range, orow As Range
Set orange = ThisWorkbook.Names("Proj_range").RefersToRange
'load each into a list and sort ascending
Dim i As Long
ReDim list(orange.Rows.Count)
For i = 0 To orange.Rows.Count
If orange.Rows.Value(i + 1, 1) = "" Then Exit For
list(i).text = Trim(orange.Rows.Value(i + 1) & " (" &
orange.Rows.Value(i + 1) & ")")
list(i).id = orange.Rows.Value(i + 1)
Me.ListBox1.AddItem orow.Value(1) & " (" & orow.Value(1) & ")"
Next
ReDim Preserve list(i - 1)
sort list
For i = 0 To UBound(list)
Me.ListBox1.AddItem list(i).text
Next
proj_id = 0
End Sub
Stan
|