Em rất mong các bác giúp đỡ. Em mù tịt về VBA. Nội dung câu hỏi như đề bài và em có nói rõ trong tệp đính kèm rồi. Cám ơn các bác nhiều lắm
Sub Macro1()
[c14:an14] = "=IF(SUM(R[-3]C:R[-1]C)>SUM(R[-6]C:R[-4]C),IF(SUM(R[-4]C:R[-1]C)>SUM(R[-8]C:R[-5]C),IF(SUM(R[-5]C:R[-1]C)>SUM(R[-10]C:R[-6]C),IF(SUM(R[-6]C:R[-1]C)>SUM(R[-12]C:R[-7]C),R[-13]C,""""),""""),""""),"""")"
[c14:an14] = [c14:an14].Value
End Sub
Option Explicit
[B]Function TongLuyTien(LookUpRange As Range, Val_ As Range)[/B]
Dim jJ As Long, Nua As Long, Rng As Range
jJ = LookUpRange.Cells.Count [COLOR=green]'jJ=12'[/COLOR]
Nua = jJ \ 2
Set Rng = LookUpRange.Cells(jJ, 1)
With Application.WorksheetFunction
'[COLOR=darkred] MsgBox Rng.Offset(1 - jJ + 6).Resize(Nua - 3).Address, _[/COLOR]
[COLOR=darkred] , Rng.Offset(1 - Nua + 3).Resize(Nua - 3).Address '[/COLOR]
If .Sum(Rng.Offset(1 - jJ).Resize(Nua)) < _
.Sum(Rng.Offset(1 - Nua).Resize(Nua)) And _
.Sum(Rng.Offset(1 - jJ + 2).Resize(Nua - 1)) < _
.Sum(Rng.Offset(1 - Nua + 1).Resize(Nua - 1)) And _
.Sum(Rng.Offset(1 - jJ + 4).Resize(Nua - 2)) < _
.Sum(Rng.Offset(1 - Nua + 2).Resize(Nua - 2)) And _
.Sum(Rng.Offset(1 - jJ + 6).Resize(Nua - 3)) < _
.Sum(Rng.Offset(1 - Nua + 3).Resize(Nua - 3)) And _
"GPE.COM" <> "GPE.NET" Then
TongLuyTien = Val_.Value
Else
TongLuyTien = Space(1)
End If
End With
[B]End Function[/B]