Hello,
I'm currently using a Textbox and a listbox to make a search form for my spreadsheet.
Currently you can search using any of the data in a row and it'll pull one line to the listbox, but won't show any duplicates with slightly different information etc.
I need it to show any data matching any of the cells.
Can anyone help me?
Private Sub CommandButton2_Click()
Dim i As Long
Me.listboxsearch.Clear
'Column Headers
Me.listboxsearch.AddItem
For A = 1 To 5
Me.listboxsearch.List(0, A - 1) = Sheet1.Cells(1, A)
Next A
Me.listboxsearch.Selected(0) = True
'Grabbing information from the columns.
For i = 2 To Sheet1.Range("A1000000").End(xlUp).Offset(1, 0).Row
For J = 1 To 5
H = Application.WorksheetFunction.CountIf(Sheet1.Range("A" & 2, "E" & i), Sheet1.Cells(i, J))
If H = 1 And LCase(Sheet1.Cells(i, J)) = LCase(Me.TextBox1) Or H = 1 And Sheet1.Cells(i, J) = Val(Me.TextBox1) Then
Me.listboxsearch.AddItem
For X = 1 To 5
Me.listboxsearch.List(listboxsearch.ListCount - 1, X - 1) = Sheet1.Cells(i, X)
Next X
End If
Next J
Next i
End Sub
Thanks guys
Bookmarks