Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function SumByColor(CellColor As Range, rRange As Range)
'Thêm dòng này để công thức tự update với Excel 2010 trở lên
' Với Excel 2007, có thể dùng CTRL + ALT + F9
Application.Volatile True
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.SUM(cl, cSum)
'~~> cSum = cSum + cl
End If
Next cl
SumByColor = cSum
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.