could not set list property,invalid property value

  • hai,


    i am having a trouble with my application. I have a textbox, commandbutton and 27 column count. i want to search for "YEAR" which is in cell M2:M on excel and display all data regarding that year in listbox on my userform. i keep on getting error message of could not set list property,invalid property value on line ListBox1.List(liste, 10) = isim.Offset(0, 10). can someone tell me what is wrong with the code??


  • Re: could not set list property,invalid property value


    try this version


    [vb] Dim a, o() As Variant, n As Long
    Dim i As Long, c As Long

    Me.ListBox1.RowSource = vbNullString
    Me.ListBox1.Clear
    Me.ListBox1.ColumnCount = 27


    a = Range("M2:M" & Range("C" & Rows.Count).End(xlUp).Row).Resize(, 27).Value2
    ReDim o(1 To 27, 1 To UBound(a, 1))

    For i = 1 To UBound(a, 1)
    If UCase(a(i, 1)) Like UCase(Me.TextBox1.Value) & "*" Then
    n = n + 1
    For c = 1 To UBound(a, 2)
    o(c, n) = a(i, c)
    Next
    End If
    Next

    If n Then
    ReDim Preserve o(1 To 27, 1 To n)
    Me.ListBox1.List = Application.Transpose(o)
    End If[/vb]

  • Re: could not set list property,invalid property value


    hai, sorry for late reply.. i have been coping with work and study these days. i tried your code and it works. but i have a problem where it only display data from cells "M" to "AC" when my data actually start from cells "C". can you tell me why?? Thank you

  • Re: could not set list property,invalid property value


    tried that before but it turned out to be, the search field will be from cell "C" not from cell "M"
    cell c is the user ID
    while cell M is the year


    example:
    when i enter "1968" it will not display any data as in the data not exist(i only have 200++ data) ..but when i enter "19", all ID that consist 19 will display on listbox (example: 19,190,191,,,,)

  • Re: could not set list property,invalid property value


    [vb]a = Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row).Resize(, 27).Value2
    Redim o(1 To 27, 1 To UBound(a, 1))

    For i = 1 To UBound(a, 1)
    If UCase(a(i, 11)) Like UCase(Me.TextBox1.Value) & "*" Then
    n = n + 1
    For c = 1 To UBound(a, 2)
    o(c, n) = a(i, c)
    Next
    End If
    Next[/vb]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!