Sub test()
On Error Resume Next
Application.ScreenUpdating = False
Application.EnableEvents = False
Sheet5.Activate
Sheet5.ShowAllData
Sheet5.Range(Sheet5.Range("A9"), Sheet5.Range("A1048576")).EntireRow.ClearContents
Dim arr
Dim i, j
Dim sArray
Dim DK_1, DK_2
j = 9
DK_1 = Sheet5.Range("D1").Value
DK_2 = Sheet5.Range("D2").Value
arr = Sheet1.Range(Sheet1.Range("A4"), Sheet1.Range("A1048576").End(xlUp).Offset(0, 10)).Value
If DK_2 = 0 Then
For i = LBound(arr, 1) To UBound(arr, 1)
If arr(i, 4) = DK_1 And arr(i, 5) = DK_1 Then
Sheet5.Range("A" & j & "
" & j).Value = Sheet1.Range("A" & i + 3 & "
" & i + 3).Value
Sheet5.Cells(j, 5).Value = arr(i, 6)
Sheet5.Cells(j, 6).Value = arr(i, 6)
Sheet5.Range("G" & j & ":K" & j).Value = Sheet1.Range("G" & i + 3 & ":K" & i + 3).Value
j = j + 1
ElseIf arr(i, 4) = DK_1 Then
Sheet5.Range("A" & j & ":C" & j).Value = Sheet1.Range("A" & i + 3 & ":C" & i + 3).Value
Sheet5.Cells(j, 4).Value = arr(i, 5)
Sheet5.Cells(j, 5).Value = arr(i, 6)
Sheet5.Range("G" & j & ":K" & j).Value = Sheet1.Range("G" & i + 3 & ":K" & i + 3).Value
j = j + 1
ElseIf arr(i, 5) = DK_1 Then
Sheet5.Range("A" & j & ":C" & j).Value = Sheet1.Range("A" & i + 3 & ":C" & i + 3).Value
Sheet5.Cells(j, 4).Value = arr(i, 4)
Sheet5.Cells(j, 6).Value = arr(i, 6)
Sheet5.Range("G" & j & ":K" & j).Value = Sheet1.Range("G" & i + 3 & ":K" & i + 3).Value
j = j + 1
End If
Next i
End If
If DK_2 <> 0 Then
For i = LBound(arr, 1) To UBound(arr, 1)
If arr(i, 4) = DK_1 And arr(i, 5) = DK_1 And (DK_2 = arr(i, 8) Or DK_2 = arr(i, 9)) Then
Sheet5.Range("A" & j & "
" & j).Value = Sheet1.Range("A" & i + 3 & "
" & i + 3).Value
Sheet5.Cells(j, 5).Value = arr(i, 6)
Sheet5.Cells(j, 6).Value = arr(i, 6)
j = j + 1
ElseIf arr(i, 4) = DK_1 And (arr(i, 8) = DK_2 Or arr(i, 9) = DK_2) Then
Sheet5.Range("A" & j & ":C" & j).Value = Sheet1.Range("A" & i + 3 & ":C" & i + 3).Value
Sheet5.Cells(j, 4).Value = arr(i, 5)
Sheet5.Cells(j, 5).Value = arr(i, 6)
Sheet5.Range("G" & j & ":K" & j).Value = Sheet1.Range("G" & i + 3 & ":K" & i + 3).Value
j = j + 1
ElseIf arr(i, 5) = DK_1 And (arr(i, 8) = DK_2 Or arr(i, 9) = DK_2) Then
Sheet5.Range("A" & j & ":C" & j).Value = Sheet1.Range("A" & i + 3 & ":C" & i + 3).Value
Sheet5.Cells(j, 4).Value = arr(i, 4)
Sheet5.Cells(j, 6).Value = arr(i, 6)
Sheet5.Range("G" & j & ":K" & j).Value = Sheet1.Range("G" & i + 3 & ":K" & i + 3).Value
j = j + 1
End If
Next i
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub