• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

problem search in sheet and show result in listbox

alhagag

Member
actaully i have problem in this code he ask me define a variable but i copy this the same code from websites and it doesn't define avariable and works but me it doesn't
any body can help me, please
Private Sub CommandButton1_Click()
Dim i, a, j, x, h As Long
Me.ListBox1.Clear
'for column header
Me.ListBox1.AddItem
For a = 1 To 5
Me.ListBox1.List(0, a - 1) = ورقة1.Cells(1, a)
Next a
Me.ListBox1.Selected(0) = True
'for listbox fill
For i = 2 To ورقة1.Range("a100000").End(xlUp).Offset(1, 0).Row
For j = 1 To 5
h = Application.WorksheetFunction.CountIf(ورقة1.Range("a" & 2, "e" & i), -ورقة1.Cells(i, j))
If h = 1 And LCase(ورقة1.Cells(i, j)) = LCase(Me.TextBox1) Or h = 1 And -ورقة1.Cells(i, j) = Val(Me.TextBox1) Then
Me.ListBox1.AddItem
For x = 1 To 5

Me.ListBox1.List(ListBox1.ListCount - 1, x - 1) = ورقة1.Cells(i, x)
Next x
End If
Next j
Next i
End Sub
 

Attachments

  • listbox1.xlsm
    17.9 KB · Views: 6
The syntax for countif is
COUNTIF( range, criteria )


I am not sure what the "-" in front of your sheet name does for you.
 
The syntax for countif is
COUNTIF( range, criteria )


I am not sure what the "-" in front of your sheet name does for you.

but when i pass the curse of mouse over code show me what i search in textbox1 also i ever told you just copy this code from websites but seems something in my file needs adjusting so far i no know it
 

Attachments

  • 553.JPG
    553.JPG
    23.5 KB · Views: 2
Back
Top