السلام عليكم
استخدم التعديل التالى
CODE
Option Explicit
Private Sub TextBox1_Change()
Dim sh As Worksheet
Set sh = Sheets("data2")
Dim i As Long
Dim x As Long
Dim p As Long
Me.ListBox1.Clear
'For Listbox Header
Me.ListBox1.AddItem "التاريخ"
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "العميل"
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = "الصنف"
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = "مبلغ"
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "سداد"
Me.ListBox1.List(ListBox1.ListCount - 1, 5) = "ملاحظات"
Me.ListBox1.List(ListBox1.ListCount - 1, 6) = "ترصيد"
Me.ListBox1.Selected(0) = True
For i = 2 To sh.Range("B" & Rows.Count).End(xlUp).Row
For x = 1 To Len(sh.Cells(i, 2))
p = Me.TextBox1.TextLength
If LCase(Mid(sh.Cells(i, 2), x, p)) = Me.TextBox1 And Me.TextBox1 <> "" Then
With Me.ListBox1
.AddItem sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 0) = sh.Cells(i, 1)
.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 2) = sh.Cells(i, 3)
.List(ListBox1.ListCount - 1, 3) = sh.Cells(i, 4)
.List(ListBox1.ListCount - 1, 4) = sh.Cells(i, 5)
.List(ListBox1.ListCount - 1, 5) = sh.Cells(i, 6)
If .ListCount - 1 = 1 Then
.List(ListBox1.ListCount - 1, 6) = .List(ListBox1.ListCount - 1, 3) - .List(ListBox1.ListCount - 1, 4)
Else
.List(ListBox1.ListCount - 1, 6) = .List(ListBox1.ListCount - 1, 3) - .List(ListBox1.ListCount - 1, 4) + .List(ListBox1.ListCount - 2, 6)
End If
End With
End If
Next x
Next i
End Sub