Created
December 22, 2016 09:40
-
-
Save ndthanh/da9e458d8e47eb84bdbcf1c78f2bb432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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