Sub TaochitietNXT()
Dim duLieu, ketQua
Dim tuNgay, denNgay As Date, timMahang As String
Dim i, k As Long
On Error Resume Next
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
tuNgay = Sheet7.Range("D7").Value
denNgay = Sheet7.Range("D8").Value
timMahang = Sheet7.Range("D9").Value
duLieu = Sheet4.Range("A11:K" & Sheet4.Range("H999999").End(xlUp).Row).Value
ReDim ketQua(1 To UBound(duLieu), 1 To 6)
For i = 1 To UBound(duLieu)
If duLieu(i, 3) >= tuNgay And duLieu(i, 3) <= denNgay And duLieu(i, 7) = timMahang Then
k = k + 1
ketQua(k, 1) = duLieu(i, 2)
ketQua(k, 2) = duLieu(i, 3)
ketQua(k, 3) = duLieu(i, 4)
ketQua(k, 4) = duLieu(i, 5)
ketQua(k, 5) = duLieu(i, 6)
ketQua(k, 6) = "x"
End If
Next i
With Sheet7
.Range("F15:F1000").AutoFilter Field:=1
.Range("A15:F1000").ClearContents
.Range("A15").Resize(k, 6).Value = ketQua
.Range("F15:F1000").AutoFilter Field:=1, Criteria1:="x", Operator:=xlFilterValues
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub