iancook1982
New Member
- Joined
- Jun 14, 2010
- Messages
- 13
Hi,
I am trying to populate a multicolumn listbox on a form from the same workbook as the form is in. Here's what I have.
'define ranges
Dim SourceData As Range
Dim FundCount As Range
Dim records As Integer
Worksheets("clientlist").Select
Range("S1").Select
Range(Selection, Selection.End(xlDown)).Select
Set SourceData = Selection
records = Selection.Count
Range("T1").Select
Range(Selection, Selection.End(xlDown)).Select
Set FundCount = Selection
Dim ListItems As Variant
Dim i As Integer
With Me.ClientList
.Clear
.ColumnCount = 2
ListItems = SourceData.Cells.Value
ListItems = Application.WorksheetFunction.Transpose(ListItems)
For i = 0 To records
.AddItem
.List(i, 0) = SourceData(i)
.List(i, 1) = FundCount(i)
Next i
End With
The first part sets the arrays, then the 2nd tries to fill the listbox. But it bugs out at:
.List(i, 0) = SourceData(i)
Can you help? What have I missed?
Thanks,
Ian.
I am trying to populate a multicolumn listbox on a form from the same workbook as the form is in. Here's what I have.
'define ranges
Dim SourceData As Range
Dim FundCount As Range
Dim records As Integer
Worksheets("clientlist").Select
Range("S1").Select
Range(Selection, Selection.End(xlDown)).Select
Set SourceData = Selection
records = Selection.Count
Range("T1").Select
Range(Selection, Selection.End(xlDown)).Select
Set FundCount = Selection
Dim ListItems As Variant
Dim i As Integer
With Me.ClientList
.Clear
.ColumnCount = 2
ListItems = SourceData.Cells.Value
ListItems = Application.WorksheetFunction.Transpose(ListItems)
For i = 0 To records
.AddItem
.List(i, 0) = SourceData(i)
.List(i, 1) = FundCount(i)
Next i
End With
The first part sets the arrays, then the 2nd tries to fill the listbox. But it bugs out at:
.List(i, 0) = SourceData(i)
Can you help? What have I missed?
Thanks,
Ian.