Hi all,
I am working on a spreadsheet with 14 columns. When i search for a value in the first column and try to populate a list box with the matching value and row. I am getting the following error
Run-Time Error '380': Could not set the list property. invalid property value.
The code i am using for populating the list box is shown.
I was able to utilize the code for a 10 column spreadsheet. I updated it for use on the 14 column spreadsheet but i am stuck. The code stops on the line with
.List(.ListCount - 1, 10) = c.Offset(0, 10).Value.
Any ideas what i am doing wrong?
Thank you for all your help
Sub Findall2()
Dim STRFIND As String 'what to find
Dim rFilter As Range 'range to search
Set rFilter = Sheet2.Range("a3", Range("n65536").End(xlUp))
Set rng = Sheet2.Range("a2", Range("a65536").End(xlUp))
STRFIND = Me.TextBoxArrest.Value
With Sheet2
If Not .AutoFilterMode Then .Range("A3").AutoFilter
rFilter.AutoFilter Field:=1, Criteria1:=STRFIND
Set rng = rng.Cells.SpecialCells(xlCellTypeVisible)
Me.ListBox1.Clear
For Each c In rng
With Me.ListBox1
.AddItem c.Value
.List(.ListCount - 1, 1) = c.Offset(0, 1).Value
.List(.ListCount - 1, 2) = c.Offset(0, 2).Value
.List(.ListCount - 1, 3) = c.Offset(0, 3).Value
.List(.ListCount - 1, 4) = c.Offset(0, 4).Value
.List(.ListCount - 1, 5) = c.Offset(0, 5).Value
.List(.ListCount - 1, 6) = c.Offset(0, 6).Value
.List(.ListCount - 1, 7) = c.Offset(0, 7).Value
.List(.ListCount - 1, 8) = c.Offset(0, 8).Value
.List(.ListCount - 1, 9) = c.Offset(0, 9).Value
.List(.ListCount - 1, 10) = c.Offset(0, 10).Value
.List(.ListCount - 1, 11) = c.Offset(0, 11).Value
.List(.ListCount - 1, 12) = c.Offset(0, 12).Value
.List(.ListCount - 1, 13) = c.Offset(0, 13).Value
End With
Next c
End With
End Sub
Bookmarks