I have a button that when clicked populates a listbox from a sheet ("Data") based on a filter set by a value in a textbox (TextBox1) on the userform. The code seems to bomb out at the line below regardless of what column I enter. It appears that maybe it doesn't want to go above 9 for some reason.
The function that is called when the button is clicked is below.
I Initialize the Listbox when form is opened:
If I change the counter to 9, column count to 10, and do not add the last 3 columns to my If statement, the listbox populates correctly.
Ideas anyone?
Runtime error 380 states that it could not set the List Property as it is an invalid property value. It doesn't seen to like values above 9.
Code:
ListBox1.List(s, 10) = Cells(sat, "K")
The function that is called when the button is clicked is below.
Code:
Private Sub ListBox1AFill()
Dim sat, s As Long
Dim deg1, deg2 As String
With ListBox1
.Clear
.ColumnCount = 13
.ColumnWidths = "70;140;40;45;45;45;40;40;40;50;50;150;50"
End With
deg2 = TextBox1.value
Debug.Print deg2
For sat = 2 To Cells(65536, "A").End(xlUp).Row
Set deg1 = Cells(sat, "A")
Debug.Print deg1
Debug.Print s
If deg1 = deg2 Then
ListBox1.AddItem
ListBox1.List(s, 0) = Cells(sat, "A")
ListBox1.List(s, 1) = Cells(sat, "B")
ListBox1.List(s, 2) = Cells(sat, "C")
ListBox1.List(s, 3) = Cells(sat, "D")
ListBox1.List(s, 4) = Cells(sat, "E")
ListBox1.List(s, 5) = Cells(sat, "F")
ListBox1.List(s, 6) = Cells(sat, "G")
ListBox1.List(s, 7) = Cells(sat, "H")
ListBox1.List(s, 8) = Cells(sat, "I")
ListBox1.List(s, 9) = Cells(sat, "J")
ListBox1.List(s, 10) = Cells(sat, "K")
ListBox1.List(s, 11) = Cells(sat, "L")
ListBox1.List(s, 12) = Cells(sat, "M")
s = s + 1
End If: Next
For s = 1 To 13
Controls("TextBox" & s) = ""
Next
End Sub
I Initialize the Listbox when form is opened:
Code:
'MultiPage1.Pages("Page1").Visible = True
ListBox1.ColumnWidths = "70;140;40;45;45;45;40;40;40;50;50;150;50"
ListBox1.ColumnCount = 13
ListBox1.List = Sheets("Data").Range("A2:M" & [a65536].End(3).Row).value
'MultiPage1.Pages("Page1").Visible = True
TextBox15.value = ListBox1.ListCount
If I change the counter to 9, column count to 10, and do not add the last 3 columns to my If statement, the listbox populates correctly.
Ideas anyone?
Runtime error 380 states that it could not set the List Property as it is an invalid property value. It doesn't seen to like values above 9.