في حدث Private Sub Worksheet_Activate ضع الكود التالي
Private Sub Worksheet_Change(ByVal Target As Range)
Dim a, i&, k&, b$, S$, lRow&
Dim WS As Worksheet: Set WS = Sheets("البيانات")
Dim desWS As Worksheet: Set desWS = Sheets("البحث")
b = desWS.[E2]
On Error Resume Next
Application.ScreenUpdating = False
If Not Intersect(Target, Target.Worksheet.Range("E2")) Is Nothing Then
If Target.Cells.Value = "" Or IsEmpty(Target) Then Exit Sub
desWS.Range("A5:j" & Rows.Count).ClearContents
a = WS.Range("A3:J" & WS.[a65000].End(xlUp).Row)
For i = 1 To UBound(a)
If a(i, 4) = b Or a(i, 7) = b Or a(i, 10) = b Then
desWS.Cells(k + 5, 1).Resize(, 10) = Application.IfError(Application.Index(a, i, Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), "")
k = k + 1
ActiveWindow.DisplayZeros = False
End If
Next
lRow = desWS.Range("A:J").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set Rng = desWS.Range("A5 :J" & lRow)
desWS.Range("A5:J500").Borders.LineStyle = xlNone
For Each c In Rng.Rows
If WorksheetFunction.CountA(c) > 0 Then c.Borders.LineStyle = xlContinuous
Next
Application.ScreenUpdating = True
End If
End Sub
السيارات 24.xlsb