وعليكم السلام ورحمة الله تعالى وبركاته
بطريقة أخرى
Sub TaxCivil()
Dim Irow&, lastRow&, lastCol&, i&, j&, k&, WS As Worksheet, dest As Worksheet, tmp As Double, _
OnRng As Variant, r As Variant, headers As Variant, n As Double, civil As String
Set WS = Sheets("المعلومات")
Set dest = Sheets("الموظفين")
Application.ScreenUpdating = False
Irow = dest.Cells(dest.Rows.Count, 3).End(xlUp).Row
lastRow = WS.Cells(WS.Rows.Count, 1).End(xlUp).Row
lastCol = WS.Cells(2, WS.Columns.Count).End(xlToLeft).Column
OnRng = dest.Range("A2:E" & Irow).Value
r = WS.Range(WS.Cells(3, 1), WS.Cells(lastRow, lastCol)).Value
headers = WS.Range(WS.Cells(2, 3), WS.Cells(2, lastCol)).Value
dest.Range("E2:E" & Irow).ClearContents
For i = 1 To UBound(OnRng, 1)
n = OnRng(i, 3): civil = OnRng(i, 4)
tmp = 0
If n = 0 Or Trim(civil) = "" Then GoTo SkipRow
For j = 1 To UBound(r, 1)
If n >= r(j, 1) And n <= r(j, 2) Then
For k = 1 To UBound(headers, 2)
If headers(1, k) = civil Then
tmp = r(j, k + 2)
Exit For
End If
Next k
Exit For
End If
Next j
OnRng(i, 5) = IIf(tmp > 0, tmp, "غير محدد")
SkipRow:
Next i
dest.Range("A2").Resize(UBound(OnRng, 1), 5).Value = OnRng
Application.ScreenUpdating = True
End Sub
ضريبة.xlsb