2020Rivalry
New Member
- Joined
- Apr 12, 2022
- Messages
- 35
- Office Version
- 365
- Platform
- Windows
The screenshot for my userform:
I implemented the code to filter using txtSearch.value (the textbox below Search by SAP Code) just now:
However, new problem appear as my previous code included listbox_double click activity, meaning after I click the filtered data, my other textboxes will track the specific filtered data:
VBA Code:
But now after I double click the specific filtered data, error occur:
And seems like code cannot capture the column heads:
Really appreciate some help, thanks!
I implemented the code to filter using txtSearch.value (the textbox below Search by SAP Code) just now:
VBA Code:
Private Sub txtSearch_Change()
Dim myList As Variant, Rws As Variant
Dim FoundSomething As Boolean
With Sheets("Sheet1")
With .Range("A6:N" & .Range("A" & Rows.Count).End(xlUp).Row)
Rws = Filter(.Worksheet.Evaluate(Replace("transpose(if(isnumber(search(""" & Me.txtSearch.Value & """,@)),row(@)-min(row(@))+1,false))", "@", .Columns(1).Address)), False, False)
If UBound(Rws) < 0 Then
FoundSomething = True
ElseIf UBound(Rws) = 0 Then
myList = .Parent.Range("A" & Rws(0) + .Row - 1).Resize(, 14).Value
Else
myList = Application.Index(.Value, Application.Transpose(Rws), [sequence(,14)])
End If
End With
End With
If Not FoundSomething Then
ListBox.RowSource = ""
ListBox.ColumnCount = 14
ListBox.ColumnHeads = True
ListBox.ColumnWidths = "55,220,100,100,70,70,70,55,130,80,80,70,150,150"
ListBox.List = myList
Else
Call Refresh_data
End If
End Sub
However, new problem appear as my previous code included listbox_double click activity, meaning after I click the filtered data, my other textboxes will track the specific filtered data:
VBA Code:
VBA Code:
Private Sub ListBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
txtSearch.Text = Me.ListBox.Column(0)
txtSearch1.Text = Me.ListBox.Column(2)
txtSAPCode.Text = Me.ListBox.Column(0)
txtSAPDescription.Text = Me.ListBox.Column(1)
txtBookingNo.Text = Me.ListBox.Column(2)
txtShipmentNo.Text = Me.ListBox.Column(3)
txtPONo.Text = Me.ListBox.Column(4)
txtDateFrom.Text = Me.ListBox.Column(5)
txtDateTo.Text = Me.ListBox.Column(6)
txtQuantity.Text = Me.ListBox.Column(7)
txtManufacturingDate.Text = Me.ListBox.Column(8)
txtCapsuleBatch1.Text = Me.ListBox.Column(9)
txtCapsuleBatch2.Text = Me.ListBox.Column(10)
txtDateofDespatch.Text = Me.ListBox.Column(11)
txtTrackSubmittedBy.Text = Me.ListBox.Column(12)
txtTrackSubmittedOn.Text = Me.ListBox.Column(13)
End Sub
But now after I double click the specific filtered data, error occur:
And seems like code cannot capture the column heads:
Really appreciate some help, thanks!