maghari
12-15-2019, 03:17 AM
hello
i have error about my code when i choose in combobox and write in textbox it gives me highlight this
If Application.WorksheetFunction.Search(M, Q, 0) = 1 Then
and gives me error
run time 1004
and this is my code
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)'
On Error Resume Next
ii = 2
For i = 0 To Me.ListBox1.ColumnCount
Me.Controls("TextBox" & ii).Value = Me.ListBox1.List(ListBox1.ListIndex, i)
ii = ii + 1
Next
End Sub
Private Sub TextBox1_Change()
' On Error Resume Next
Dim ws As Worksheet Dim V As Integer
Dim LastRow As Long
Dim M As String
Dim Q, F
ListBox1.Clear
If TextBox1.Text = "" Then GoTo 1
M = TextBox1.Text
Set ws = Sheets("Data")
With ws
x = ComboBox1.ListIndex + 2
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set Q = Range(.Cells(2, x), .Cells(LastRow, x)).Find(M)
If Not Q Is Nothing Then
F = Q.Address
Do
If Application.WorksheetFunction.Search(M, Q, 0) = 1 Then
ListBox1.AddItem Q.Row
ListBox1.List(V, 1) = .Cells(Q.Row, 2).Value
ListBox1.List(V, 2) = .Cells(Q.Row, 3).Value
ListBox1.List(V, 3) = .Cells(Q.Row, 4).Text
ListBox1.List(V, 4) = .Cells(Q.Row, 5).Value
ListBox1.List(V, 5) = .Cells(Q.Row, 6).Value
ListBox1.List(V, 6) = .Cells(Q.Row, 7).Value
ListBox1.List(V, 7) = .Cells(Q.Row, 8).Value
ListBox1.List(V, 8) = .Cells(Q.Row, 9).Value
V = V + 1
End If
Set Q = Range(.Cells(2, x), .Cells(LastRow, x)).FindNext(Q)
Loop While
Not Q Is Nothing And Q.Address <> F
End If
End With1
End Sub
attached file
i have error about my code when i choose in combobox and write in textbox it gives me highlight this
If Application.WorksheetFunction.Search(M, Q, 0) = 1 Then
and gives me error
run time 1004
and this is my code
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)'
On Error Resume Next
ii = 2
For i = 0 To Me.ListBox1.ColumnCount
Me.Controls("TextBox" & ii).Value = Me.ListBox1.List(ListBox1.ListIndex, i)
ii = ii + 1
Next
End Sub
Private Sub TextBox1_Change()
' On Error Resume Next
Dim ws As Worksheet Dim V As Integer
Dim LastRow As Long
Dim M As String
Dim Q, F
ListBox1.Clear
If TextBox1.Text = "" Then GoTo 1
M = TextBox1.Text
Set ws = Sheets("Data")
With ws
x = ComboBox1.ListIndex + 2
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set Q = Range(.Cells(2, x), .Cells(LastRow, x)).Find(M)
If Not Q Is Nothing Then
F = Q.Address
Do
If Application.WorksheetFunction.Search(M, Q, 0) = 1 Then
ListBox1.AddItem Q.Row
ListBox1.List(V, 1) = .Cells(Q.Row, 2).Value
ListBox1.List(V, 2) = .Cells(Q.Row, 3).Value
ListBox1.List(V, 3) = .Cells(Q.Row, 4).Text
ListBox1.List(V, 4) = .Cells(Q.Row, 5).Value
ListBox1.List(V, 5) = .Cells(Q.Row, 6).Value
ListBox1.List(V, 6) = .Cells(Q.Row, 7).Value
ListBox1.List(V, 7) = .Cells(Q.Row, 8).Value
ListBox1.List(V, 8) = .Cells(Q.Row, 9).Value
V = V + 1
End If
Set Q = Range(.Cells(2, x), .Cells(LastRow, x)).FindNext(Q)
Loop While
Not Q Is Nothing And Q.Address <> F
End If
End With1
End Sub
attached file