Sub Phan_Bo1()
Dim a(), lRow As Long, sMatch As String, eMatch As String
Dim Res(), TT As Double, KH As Double, i As Long, j As Long
With Sheet5
lRow = .Range("A" & Rows.Count).End(xlUp).Row
a = .Range("A7:S" & lRow).Value
lRow = UBound(a, 1)
ReDim Res(1 To lRow, 1 To 1)
For i = 1 To lRow
sMatch = a(i, 1) & "#" & a(i, 2) & "#" & a(i, 3) & "#" & a(i, 4) & "#" & a(i, 5)
TT = 0: KH = 0
'Xac dinh so Tieu_thu
For j = 1 To lRow
eMatch = a(j, 1) & "#" & a(j, 2) & "#" & a(j, 3) & "#" & a(j, 4) & "#" & a(j, 5)
If sMatch = eMatch Then TT = TT + a(j, 18)
Next j
'Xac dinh so Ke_hoach
For j = 1 To lRow
eMatch = a(j, 1) & "#" & a(j, 2) & "#" & a(j, 3) & "#" & a(j, 4) & "#" & a(j, 5)
If sMatch = eMatch Then KH = KH + a(j, 19)
Next j
'Tinh Phan_bo
Res(i, 1) = a(i, 19) * TT / KH
Next i
.Range("U7").ClearContents
.Range("U7").Resize(lRow, 1) = Res
End With
End Sub