Hi.
I have this code for populating a listview box that works almost perfectly...
What I want here, is to the listview box returns the data filtered by the content of the TextBox1
I have this code for populating a listview box that works almost perfectly...
What I want here, is to the listview box returns the data filtered by the content of the TextBox1
Code:
Private Sub UserForm_Initialize()
Dim Item As ListItem
Dim LinhaFinal As Integer
Dim i As Integer
Sheets("JOBDATA").Select
ActiveSheet.ListObjects("JOBDATA").Range.AutoFilter Field:=10, Criteria1:="LCZ"
TextBox1.Text = Sheet5.Cells(5, 14)
With ListView1
.Gridlines = False
.View = lvwReport
.FullRowSelect = True
.ColumnHeaders.Add Text:="Created Date", Width:=80
.ColumnHeaders.Add Text:="Booking Date", Width:=80
.ColumnHeaders.Add Text:="Job Number", Width:=80
.ColumnHeaders.Add Text:="Consigment ID", Width:=80
.ColumnHeaders.Add Text:="Shipper", Width:=80
.ColumnHeaders.Add Text:="Origin Country", Width:=80
.ColumnHeaders.Add Text:="Destination Country", Width:=80
.ColumnHeaders.Add Text:="Total Units", Width:=80
.ColumnHeaders.Add Text:="Volume (cu/m)", Width:=80
.ColumnHeaders.Add Text:="Weight (kg)", Width:=80
End With
ListView1.ListItems.Clear
LinhaFinal = Sheet2.Cells(Rows.Count, 50).End(xlUp).Row
For i = 2 To LinhaFinal
If Sheet5.Cells(5, 14).Value = TextBox1.Text Then
Set Item = ListView1.ListItems.Add(, , Sheet5.Cells(5, 14))
Item.SubItems(1) = Sheet2.Cells(i, 51)
Item.SubItems(2) = Sheet2.Cells(i, 52)
Item.SubItems(3) = Sheet2.Cells(i, 53)
Item.SubItems(4) = Sheet2.Cells(i, 54)
Item.SubItems(5) = Sheet2.Cells(i, 55)
Item.SubItems(6) = Sheet2.Cells(i, 56)
Item.SubItems(7) = Sheet2.Cells(i, 57)
Item.SubItems(8) = Sheet2.Cells(i, 58)
Item.SubItems(9) = Sheet2.Cells(i, 59)
End If
Next
End Sub