I have created a user form called ProjectSelection. On the userform I have a ListBox called PrjList. The listbox will have 5 columns. The example needs to display 30 lines.
In the ProjectSelection code screen I have a module called UserForm_Initialize(). The code for this module follows.
Private Sub UserForm_Initialize()
Dim row As Integer
Application.ScreenUpdating = False 'No screen updates
' Add items to the ListBox
ProjectSelection.PrjList.ColumnCount = 5
ProjectSelection.PrjList.ColumnWidths = ".5in;.5in;.5in;.5in;.5in"
For row = 0 To 30
With ProjectSelection.PrjList
.List(row, 0) = "Row(" & row & ""
.List(row, 1) = "Col(2)"
.List(row, 2) = "Col(3)"
.List(row, 3) = "Col(4)"
.List(row, 4) = "Col(5)"
End With
Next row
Next row
ProjectSelection.PrjList.ListIndex = -1 'No item selected
ProjectSelectionValue = -1
Application.ScreenUpdating = True 'Allow screen updates
End Sub
When this module gets invoked by way of the call:
ProjectSelection.Show
I get the following error message in a pop up window.
Run-time error '381'
Could not set the list property. Invalid property array index.
Any ideas on what I am doing wrong?
Thanks
Bob Hudson
In the ProjectSelection code screen I have a module called UserForm_Initialize(). The code for this module follows.
Private Sub UserForm_Initialize()
Dim row As Integer
Application.ScreenUpdating = False 'No screen updates
' Add items to the ListBox
ProjectSelection.PrjList.ColumnCount = 5
ProjectSelection.PrjList.ColumnWidths = ".5in;.5in;.5in;.5in;.5in"
For row = 0 To 30
With ProjectSelection.PrjList
.List(row, 0) = "Row(" & row & ""
.List(row, 1) = "Col(2)"
.List(row, 2) = "Col(3)"
.List(row, 3) = "Col(4)"
.List(row, 4) = "Col(5)"
End With
Next row
Next row
ProjectSelection.PrjList.ListIndex = -1 'No item selected
ProjectSelectionValue = -1
Application.ScreenUpdating = True 'Allow screen updates
End Sub
When this module gets invoked by way of the call:
ProjectSelection.Show
I get the following error message in a pop up window.
Run-time error '381'
Could not set the list property. Invalid property array index.
Any ideas on what I am doing wrong?
Thanks
Bob Hudson