Option Explicit
Sub PHUONGPHAP()
Dim DS(), KQ(), PP()
Dim i As Long, j As Long, K As Long, Hc As String, DK As String
DK = Sheets("BIEUMAU").Range("C3").Value
'---------------------------------------------------------------------------------
With Sheets("DULIEUNHAP")
DS = .Range("B4", .Range("B" & Rows.Count).End(xlUp)).Resize(, 22).Value
ReDim KQ(1 To UBound(DS), 1 To 5)
For j = 10 To UBound(DS, 2)
If DS(1, j) = DK Then
Exit For
End If
Next
'---------------------------------------------------------------------------------
For i = 2 To UBound(DS)
Hc = DS(i, 1)
If Hc <> "" And DS(i, j) <> "" Then
K = K + 1
KQ(K, 1) = K
KQ(K, 2) = DS(i, 1)
KQ(K, 3) = DS(i, 7)
KQ(K, 4) = DS(i, 8)
KQ(K, 5) = DS(i, 5) * DS(i, j)
End If
Next
End With
'---------------------------------------------------------------------------------
With Sheets("BIEUMAU")
.Range("B6:F" & .Range("B" & Rows.Count).End(xlUp).Row + 5).ClearContents
If K >= 1 Then
.Range("B6").Resize(K, 5) = KQ
.Range("B6").Resize(K, 5).Borders.LineStyle = 1
End If
End With
End Sub