Option Explicit
Sub SoSanhDuLieu()
Dim lRow As Long, jW As Long, jZ As Long, jJ As Long, cRow As Long, dRow As Long
Dim Rng As Range, RngC As Range
lRow = [c65432].End(xlUp).Row
Range("B38:R321").Clear
Range("F2:O2").Copy Destination:=Range("F38")
Application.ScreenUpdating = False
For jW = 18 To 23
cRow = Range(Chr(64 + jW) & 36).End(xlUp).Row
If cRow = 1 Then GoTo 17
For jJ = 3 To lRow
For jZ = 2 To cRow
If Cells(jJ, 3) = Cells(jZ, jW) Then
If Rng Is Nothing And RngC Is Nothing Then
Set Rng = Cells(jZ - 1, jW)
Set RngC = Cells(jJ, 3).Resize(1, 13)
Else
Set Rng = Union(Rng, Cells(jZ, jW))
Set RngC = Union(RngC, Cells(jJ, 3).Resize(1, 13))
End If
End If
Next jZ
Next jJ
dRow = [F65432].End(xlUp).Row + 1
If dRow > 39 Then dRow = dRow + 1
Rng.Copy Destination:=Range("B" & dRow)
RngC.Copy Destination:=Range("C" & dRow)
Set Rng = Nothing: Set RngC = Nothing
17 Next jW
End Sub