Created
August 23, 2020 15:36
-
-
Save jojijacobk/fea8f9165373df3c3b1409329cb473cb to your computer and use it in GitHub Desktop.
VBA function to get count of cells with a specific colour code
This file contains 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 GetColorCount(CountRange As Range, CountColor As Range) | |
Dim CountColorValue As Integer | |
Dim TotalCount As Integer | |
CountColorValue = CountColor.Interior.ColorIndex | |
Set rCell = CountRange | |
For Each rCell In CountRange | |
If rCell.Interior.ColorIndex = CountColorValue Then | |
TotalCount = TotalCount + 1 | |
End If | |
Next rCell | |
GetColorCount = TotalCount | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment