Sub ChamCong()
Application.ScreenUpdating = False
Dim MaNV As Integer
Range(Sheets("Cham cong").[D7], Sheets("Cham cong").[B65536].End(xlUp).Offset(, 32)).ClearContents
For Each cll In Range(Sheets("Du lieu").[A4], Sheets("Du lieu").[A65536].End(xlUp))
MaNV = Application.WorksheetFunction.Match(cll, Range(Sheets("Cham cong").[B7], Sheets("Cham cong").[B65536].End(xlUp)), 0)
'MsgBox MaNV
If cll.Offset(, 6).Value = "NL" Then
Sheets("Cham cong").[B7].Offset(MaNV - 1, Day(cll.Offset(, 2).Value) + 1).Value = "NL"
ElseIf cll.Offset(, 8).Value = 1 Then
Sheets("Cham cong").[B7].Offset(MaNV - 1, Day(cll.Offset(, 2).Value) + 1).Value = "x"
ElseIf cll.Offset(, 6).Value = "CN" Then
Sheets("Cham cong").[B7].Offset(MaNV - 1, Day(cll.Offset(, 2).Value) + 1).Value = "CN"
Else
Sheets("Cham cong").[B7].Offset(MaNV - 1, Day(cll.Offset(, 2).Value) + 1).Value = cll.Offset(, 7).Value
End If
Next
Application.ScreenUpdating = True
End Sub