brendalpzm
Board Regular
- Joined
- Oct 3, 2022
- Messages
- 59
- Office Version
- 365
- 2021
- 2019
- 2016
- Platform
- Windows
I created a list box with the following code:
and I created a text box that I want to use it as a search engine, One of the columns has full names, so I want to type the name in the text box and click a button to filter the table with the values that contain the typed values.
VBA Code:
Private Sub UserForm_Initialize()
Dim arrdata() As Variant
Dim lngIndex As Long
Dim lngRow As Long
arrdata = Worksheets("Current").Range("A1").CurrentRegion.Value
With Me.lstHeaders
.ColumnCount = 7
.ColumnWidths = "180,60,255,95,75,105,65"
.Font.Size = 13
.Font.Bold = True
.Enabled = False
.AddItem
.List(lngRow, 0) = arrdata(1, 3)
.List(lngRow, 1) = arrdata(1, 4)
.List(lngRow, 2) = arrdata(1, 5)
.List(lngRow, 3) = arrdata(1, 10)
.List(lngRow, 4) = arrdata(1, 11)
.List(lngRow, 5) = arrdata(1, 13)
.List(lngRow, 6) = arrdata(1, 14)
End With
With Me.CarList
.ColumnCount = 7
.ColumnWidths = "180,60,255,95,75,105,65"
.Font.Size = 13
End With
lngRow = 0
For lngIndex = LBound(arrdata, 1) + 1 To UBound(arrdata, 1)
If arrdata(lngIndex, 13) <> "completed" Then
With Me.CarList
.AddItem
.List(lngRow, 0) = arrdata(lngIndex, 3)
.List(lngRow, 1) = arrdata(lngIndex, 4)
.List(lngRow, 2) = arrdata(lngIndex, 5)
.List(lngRow, 3) = arrdata(lngIndex, 10)
.List(lngRow, 4) = arrdata(lngIndex, 11)
.List(lngRow, 5) = arrdata(lngIndex, 13)
.List(lngRow, 6) = arrdata(lngIndex, 14)
End With
lngRow = lngRow + 1
End If
Next lngIndex
End Sub
and I created a text box that I want to use it as a search engine, One of the columns has full names, so I want to type the name in the text box and click a button to filter the table with the values that contain the typed values.